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

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

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