Matlab: build each row of the matrix as a function of its index

I would like to create a graph with several rows, each of which corresponds to a row in a given matrix.

To be more complex, I have a matrix M, where each row represents a value that changes along the columns. I would like to build this change as a function of the column index for each of the rows, so to build (for example, the first row), you should:

plot(M(1,:)); 

The fact is that I would like to build all the lines. Of course, I could iterate over them, hold and draw the current one:

 (plot(M(i,:)) 

but I am wondering if there is a simple command or single-liner that would do this.

I tried plotmatrix , but without much success regarding the desired results.

Thanks!

+4
source share
1 answer

Have you tried plot(M') ?

From the first paragraph of the plot documentation :

plot (Y) displays the columns of Y relative to the index of each value when Y is a real number.

+9
source

All Articles