Write a function plotData(filename,markers)
- Takes an input the filename of an Excel file which contains two columns of numbers and in which the first entry of each column is a string.
- Plots a solid line graph in black representing the relation between the columns of numbers in the Excel file. The x-values of the graph should consist of the numbers in the first column, and the y-values of the graph should consist of the numbers in the second column.
- If the value of the boolean variable markers is true, the graph should plot an 'o' at each data point.
- THe x and y axis of the plot should be labeled using the respective name of the column.
- The title of the plot should be the name of the Excel file.
function [xy]= plotData(file,markers)x=xlsread('data.xlsx','A3:A9'); %this needs to be more general,
%what if you have a file where the input data is located in B4 through B12?
y=xlsread('data.xlsx','B3:B9'); %this needs to be more general,%what if you have a file where the output data is located in C4 through C12?
[num,txt]=xlsread(filename)title('data.xlsx') %needs to depend on the input variable called file
xlabel('time(sec)') %needs to depend on what’s in the Excel file
ylabel('height(meters)') %needs to depend on what’s in the Excel file
if markers==true plot(x,y,'k-o'); else plot(x,y,'k-'); end
Best Answer