Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

For an assignment I need to create a function that creates a graph using data from an imported excel file.

3 vues (au cours des 30 derniers jours)
The file has two columns in which the first entry in each column is a string. The first column should be used for x-values and the second column for y-values. The string in the first entry should be used as the label for their respective axis. The graph should plot a 'o' at each data point.
  3 commentaires
Noah Walker
Noah Walker le 28 Nov 2018
This is what I have so far
function plotData(filename,markers)
filename=xlsread('data.xlsx');
x=xlsread('data.xlsx','A3:A9'); %Assigns the first column to be
%the x-values
y=xlsread('data.xlsx','B3:B9'); %Assigns the second column to be
%the y-values
if markers==true
plot(x,y,'b-o');
else
plot(x,y);
end
title('data.xlsx')
xlabel('time(sec)');
ylabel('height(meters)');
However, my professor said that the assignment of the columns should be generalized to be able to work for any table. Also the x and y labels should be generalized, making them dependent on the table
Geoff Hayes
Geoff Hayes le 28 Nov 2018
Noah - by "generalized", i suppose this means that the columm input (i.e. A3:A9) should be configurable by being input parameters into this function. Presumably the same would be true for the x- and y-labels (or maybe you can read this from the Excel sheet).
Also, you are passing in a filename input parameter but are then not using it and are instead using the hard-coded data.xlsx. Why?

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by