(MATLAB) Write a function that will read data from the attached \"XY.dat\". This
ID: 2314769 • Letter: #
Question
(MATLAB)
Write a function that will read data from the attached "XY.dat".
This data file has a header line.
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.
x 0 y 1
x 1.3 y 2.2
The function has one input argument: the file path of the data file. The function will attempt to open the data file and errorcheck to make sure it was opened. If so, it reads in all x values and y values. Then the function closes the file.
The function shall return the x and y vectors as the output arguments.
Explanation / Answer
%Matlab code here function [x,y]=read('path') A=importdata(path); x=A.data(:,1); y=A.data(:,2); end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.