How can I read a column from excel while I do not want all the data of that column?

2 visualizzazioni (ultimi 30 giorni)
I want to plot four graphs in the same figure. I can read all of them from excel. But for first plotting i want to plot all the values of X; but the second plot I want to take the values after 5 intervals, the step size should be suppose 5, something like xmin:5: xmax. how i can do that?
plot(X,Y1, 'color','b','linewidth',2);
plot(X,Y2, 'Marker','o', 'color','b','linewidth',1);

Risposte (1)

dpb il 31 Ago 2022
It's VERY inefficient to open/read/close the same file three times, not to mention it just makes for more work to address multiple variables with sequentially-number names. The existence of such is a very good sign that MATLAB syntax isn't being used effectively.
Instead, do something more like
data=readmatrix('phasesintegrated'); % read the whole array at once
hold on % so can add to same axes
plot(data(:,1),data(:,3), 'bo-','linewidth',1);
Not sure what else, specifically you want to plot, but the "every fifth point" thing is trivial -- see <colon, :> for all the skinny on subscripting, but
would add the 2nd set of data with a red 'x' for every fifth point beginning with the first. You can change the starting index at will, too, of course.


Scopri di più su Labels and Annotations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by