Plotting multiple columns from a matrix in Matlab with a loop

2 replies · 5K views · last reply
mathia
Messages
15
Reaction score
0
Hi,
I have a matrix for instance as follow:
A=[0.087 11.43 17.14 22.86 28.57 34.29 40.00 45.72 51.43 57.15
0.174 5.671 8.506 11.34 14.17 17.01 19.84 22.68 25.52 28.35
0.261 3.732 5.598 7.464 9.330 11.19 13.06 14.92 16.79 18.66
0.349 2.747 4.121 5.494 6.868 8.242 9.616 10.98 12.36 13.73
0.436 2.144 3.216 4.289 5.361 6.433 7.505 8.578 9.650 10.72
0.523 1.732 2.598 3.464 4.330 5.196 6.062 6.928 7.794 8.660];

I want to have all of this plot:
hold all
plot(A(:,1),A(:,2))
plot(A(:,1),A(:,3))
plot(A(:,1),A(:,4))
plot(A(:,1),A(:,5))
plot(A(:,1),A(:,6))
plot(A(:,1),A(:,7))
plot(A(:,1),A(:,8))
plot(A(:,1),A(:,9))
plot(A(:,1),A(:,10))

Can I have all of those plot just by using one plot command in a loop? If this is the case how can I do?
Thank you.
Best Regards,
Mathias
 
thank you.
yes, they are separate plots.

can I change the color of each plot by using those commands?
for example I want plot(A(:,1),A(:,2)) be read, plot(A(:,1),A(:,3)) be green and so on.