Question: Problem 1: Write a script that will read from a file x and y data points in the following format: The format of every line

Problem 1: Write a script that will read from a file x and y data points in the following format:

x0 y 1 x 1.3 x 2.2 x 3.4 y 2.2 y6

The format of every line in the file is the letter ?x?, a space, the x value, space, the letter ?y?, space, and the y value. First, create the data file with 10 lines in this format. Do this by using the Editor/Debugger, then File Save As xypts.dat. The script will attempt to open the data file and error-check to make sure it was opened. If so, it uses a for loop and fgetl to read each line as a string. In the loop, it creates x and y vectors for the data points. After the loop, it plots these points and attempts to close the file. The script should print whether or not the file was successfully closed.

Problem 2: Modify the script from the previous problem. Assume that the data file is in exactly that format, but do not assume that the number of lines in the file is known. Instead of using a for loop, loop until the end of the file is reached. The number of points, however, should be in the plot title.

x0 y 1 x 1.3 x 2.2 x 3.4 y 2.2 y6 y 7.4

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve these problems we will write two MATLAB scripts Problem 1 Reading and Plotting Known Number ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

60950e99554a9_25504.pdf

180 KBs PDF File

Word file Icon

60950e99554a9_25504.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!