Hi, I am still beginner in MATLAB and I wonder how to plot multiple (hundreds) of rows into one graph? For example if I have
x=[1:5] and the my y values are y = [ 2 3 5 6 4; 4 5 6 2 10; 13 4 12 10 4; ... ] -> 100 rows or more
Is it possible to automate the plot? instead of using
plot (x,y(1,:)) hold on plot (x,y(2,:)) plot (x,y(3,:)) ... hold off
is there an easy way to plot all of those y values into a single graph? Thank you in advance for the reply

 Akzeptierte Antwort

Star Strider
Star Strider am 5 Nov. 2018

0 Stimmen

No loop necessary. MATLAB will plot these correctly for you:
x = [1:5];
y = [2 3 5 6 4; 4 5 6 2 10; 13 4 12 10 4];
figure
plot(x, y)
grid
Note that if ‘y’ is a ‘numel(x) x numel(x)’ square matrix, you may have to transpose it to get the correct plot.

2 Kommentare

Dionysius Bryan
Dionysius Bryan am 8 Nov. 2018
Thank a lot!
Star Strider
Star Strider am 8 Nov. 2018
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by