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

  Write project report and provide cross-synthesis

Write project report and provide Cross-synthesis.

  Construct the shear force and bending moment diagrams

Write the algorithm and draw the flowchart for each problem

  Compute the power spectral density vector

Compute the power spectral density vector. Plot the spectrogram using the same parameters as in lecture.

  Calculate an approximation to the energy consumed

Calculate an approximation to the energy consumed over the period and calculate an approximation to the energy consumed over the period t = a to t = b.

  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.

  Write a simple program that stores the high temperatures

A meteorological company wants you to write a simple program that stores the high temperatures and low temperates for each of the months of the year. After consulting with trusted programming partners, you come up with a great idea

  Boundary conditions for the finite element model

The computer program or the finite element model for one value of a and the excel file for finite element results processing;Boundary conditions for the finite element model

  Matlab: create a function that will use the secant method

MATLAB: Create a function that will use the Secant method

  Write a matlab function that takes in one argument

Write a MatLab function that takes in one argument, a vector or 2-D matrix and returns a single value, the highest value in the vector or matrix. Use nested for loops to accomplish this task. Assume that all of the values in the vector or matrix are ..

  Plot the lines using the inputted vector of x values and x

Write a function named solveSystem that has three inputs: two vectors consisting of coefficients [a b c] of two line equations of the form ax + by = c and a vector of x values.

  Fit the exponential function to the relaxation data

Fit the exponential function to the relaxation data and report the filename as well as the A, tau and B values and run all 3 functions in sequence to analyze ALL data

  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

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