Plotting a 2-d matrix v/s a vector

3 Ansichten (letzte 30 Tage)
Shruti Motiwale
Shruti Motiwale am 27 Jun. 2012
I want a 3-d plot such that the rows and columns of the matrix are depicted on two separate axes and the third axis shows values of the vector. How can this be done?
plot(Y,sigmab);
Currently I am using this command, in which sigmab is a matrix and Y is a vector. It plots every row with Y and thus gives me multiple graphs equal to the no. of columns on the same plot. But if I want to know that a particular graph belongs to which column no., I cannot find out.(I don't even know if it is plotting eevry row or column with Y, its just a guess.)
I thought of creating a 3-d matrix, and combining Y and sigmab together in it, but I'm not sure which command would exactly give what I want, as I want the axes to be numbered according to the range of values of the matrix, also, it would take up a lot of space, so I'm kind of avoiding it unless absolutely necessary.

Antworten (1)

Walter Roberson
Walter Roberson am 27 Jun. 2012
col_labels = cellstr( num2str((1:size(sigmab,2)).', 'Column %d') );
legend( col_labels{:} );
  3 Kommentare
Shruti Motiwale
Shruti Motiwale am 28 Jun. 2012
I figured out how it works, but I have around 80 graphs on one plot, and they are pretty close to one another, so it is a slightly impractical solution, also, it is making the program extremely slow.
Walter Roberson
Walter Roberson am 28 Jun. 2012
You want, "the third axis shows values of the vector". Which vector is that? Do you have a vector of values for each (row,column) position? If you do then that requires either a 4D plot or else a volume plot. 4D plots are difficult to create on what is really a 2D coordinate system. Volume plots are difficult to see "into".
If you have one value for each (row,column) position, then perhaps surf() is appropriate, perhaps in conjunction with turning a data cursor on so that you can determine the coordinates and value of a location by pointing to it.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by