4
votes

I would like to create a plot with several lines, each corresponding to a row at a given matrix.

To be more elaborate, I have got a matrix M where each row represents a value that is changing along the columns. I would like to plot this change as a function of the column index to each of the rows, so to plot (e.g) the first rowI should :

plot(M(1,:));

The thing is, I would like to plot all the rows. Of course I could iterate over them, hold and plot the current one:

(plot(M(i,:))

but I'm wondering if there's a simple command or a single-liner that would do it.

I have tried plotmatrix but without much success regarding the desirable results.

Thanks!

1

1 Answers

9
votes

Have you tried plot(M')?

From the first paragraph of the documentation of plot:

plot(Y) plots the columns of Y versus the index of each value when Y is a real number.