Read the file a line at a time

Assignment Help MATLAB Programming
Reference no: EM13165187

Write a function called replaceStr. Your function should take in the following (in this order): filename: A string that corresponds to the name of a file wordA: A string that is a word (contains no spaces) wordB: Another string that is also a word (contains no spaces) Your function should do the following:

a.   Read the file a line at a time.

b.   On each line, replace every occurrence of wordA with wordB.

c.   Write the modified text file with the same name as the original file, but preprended with 'new_'. For instance, if the input filename was 'data.txt', the output filename would be 'new_data.txt'.

d.   Prepare a test file by downloading a text file from the Internet. For example, the complete works of Shakespeare are accessible at https://www.william-shakespeare.info

e.   Examine the file for repeated words and test your function by writing a script that replaces frequently repeated words.

You have to use the file below in order to write the program:

from Twelfth Night, Act 2 Scene 2

I left no ring with her: what means this lady?
Fortune forbid my outside have not charm'd her!
She made good view of me; indeed, so much,
That sure methought her eyes had lost her tongue,
For she did speak in starts distractedly.
She loves me, sure; the cunning of her passion
Invites me in this churlish messenger.
None of my lord's ring! why, he sent her none.
I am the man: if it be so, as 'tis,
Poor lady, she were better love a dream.
Disguise, I see, thou art a wickedness,
Wherein the pregnant enemy does much.
How easy is it for the proper-false
In women's waxen hearts to set their forms!
Alas, our frailty is the cause, not we!
For such as we are made of, such we be.
How will this fadge? my master loves her dearly;
And I, poor monster, fond as much on him;
And she, mistaken, seems to dote on me.
What will become of this? As I am man,
My state is desperate for my master's love;
As I am woman,--now alas the day!--
What thriftless sighs shall poor Olivia breathe!
O time! thou must untangle this, not I;
It is too hard a knot for me to untie!

 

Reference no: EM13165187

Questions Cloud

Consider the molar mass of nh : You prepared a 0.250 M solution by diluting 8.45(+-0.04)mL of 28.0(+-0.5)mL wt.%NH3 (density=0.899(+-0.003)g/mL up to 500.0(+-0.2)mL. Find the uncertainty in 0.250 M.
Make a c program using cramers rule using 3 variables and eq : make a C program using cramers rule using 3 variables and 3 equations. I need help why the third variable says it isnt initialized and allow the the determinents to be calculated. also i need help making a menu allowing the user to make a start the p..
Topics: user interface, input validation, computer security : Topics: user interface, input validation, computer security, i/o processing, storage & retrievalAssignment: Write a program that will simulate a basic registration/login process for a standard application or website.Menu ItemsCreate a profileAsk the ..
Calculate the molality, molarity : An aqueous antifreeze solution is 40.0% ethylene glycol (C2H6O2) by mass. The density of the solution is 1.05 g/cm3. Calculate the molality, molarity, and mole fraction of the ethylene glycol.
Read the file a line at a time : Write the modified text file with the same name as the original file, but preprended with 'new_'. For instance, if the input filename was 'data.txt', the output filename would be 'new_data.txt'.
What is the molecular weight of the hormone : An aqueous solution containing 21.6 mg of vasopressin in 100.0 mL of solution has an osmotic pressure at 25.0 oC of 3.70 mmHg. What is the molecular weight of the hormone?
Design a 4-bit register based on four d flip-flops : Design a 4-bit register based on four D flip-flops with three inputs I (4-bit), c (2-bit), and clk, and one output A (4-bit). The register can do four different operations depending on the value
Using the expand, guess, and verify method find closed : Using the expand, guess, and verify method find closed form solutions for the following recurrence relations.
Analyze the societal implications of using this process : Discuss in detail, one way in which atomic nuclear decay takes place. What is the significance of atomic nuclear decay? Analyze the societal implications of using this process.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Make a program that will graph the parabolas

Make a program that will graph the parabolas each parabola a different color and put all the parabolas in the same figure or graph

  Write a user defined function

Write a user defined function FindFrequency which inputs are a time and a wave elevation vector and output the approximated wave frequency (fappr=FindFrequency(t,eta)).

  Matlab: create a function that will use the secant method

MATLAB: Create a function that will use the Secant method

  Kerfuffleboard is a game very much like shuffleboard

Kerfuffleboard is a game very much like Shuffleboard. Players take turns shooting disks at a trianglular scoring area. While the scoring areas are the same in shuffleboard and kerfuffleboard, a disk's contribution to a player's score will be calcu..

  Write a function that takes a list of integers

Using ML write a function that takes a list of integers as argument and returns a pair consisting of the sum of the even position and the sum of the odd positions of the list.

  Filtering – biomedical application

Prepare a filter that removes noise produced by electronic medical equipment.

  Deterministic dimensions and rebar area

Performance function for bending of a rectangular reinforced concrete beam under moments due to dead and live loads

  Fourier transform and biosignal analysis

Fourier Transform and Biosignal Analysis - series data into its frequency components for the purpose of signal analysis and processing.

  Design and fir filter in matlab

What does the pole-zero diagram tells you about the filter

  Create from the stack a structure string stac

Design a structure stack that represents a stack of elements of some arbitrary type. Include the functions: create(returns an empty stack), push(add an element to the top of the stack and return the resulting stack), pop(delete the top element and re..

  Compare two sound wave in matlab

Compare two sound wave in matlab as on speech to text processing and open as notepad, calculator,C:,D: and many other on speaking

  Matlab program to compute how much money will accumulate

Write a MATLAB program to compute how much money will accumulate in 5 years in the account and in any CDs you buy. Run the program for two different savings interest rates: 4 percent and 5 percent.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd