Reputation: 85
I am trying to plot this array:
A=[
1 1 3 3 3 3;
2 3 2 2 2 2;
3 2 1 1 1 1]
where the axis X must be the index of each column (1,2,3,4,5,6) and the axis Y must be the numbers on each column of the matrix, so I will have three line of plotting. The values So, for the value "1" I will have one continuous line plot along the X axis, for the value "2" other continuous line and another for "3".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I made a figure for the example above. I want matlab make this kind of graphics from a huge matrix.
I am having problens on plotting this matrix
The results is:
Please, if you compare the graphics with the matrix, it isn't the same as debería ser. If you see de E(4,1)=10 in Y=1, then you see the same number on Y=2, i can say that the number 10 goes from the row = '4' to row = '10' , but comparing with the graphics isn't the same (like I want).
Upvotes: 0
Views: 1406
Reputation: 112679
To plot the rows of A
and make the y axis descending:
plot(A.')
axis ij
Explanation:
help plot
: "PLOT(Y) plots the columns of Y versus their index". So plot(Y.') plots the rows of Y versus their index.help axis
: "AXIS IJ puts MATLAB into its 'matrix' axes mode. The coordinate system origin is at the upper left corner. The i axis is vertical and is numbered from top to bottom. The j axis is horizontal and is numbered from left to right."If you want to plot in which row a given number is for each column (according to your edited question):
[E_sort ind] = sort(E);
plot(ind.')
axis ij
This works if there are no gaps in the set of numbers contained in E
.
Upvotes: 2