2D plot by including third parameter as colorbar
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anju K Joshi
am 10 Mär. 2020
Kommentiert: Anju K Joshi
am 23 Mär. 2020
I have 3 matrices (X Y and Z). Among these X and Z are of same size, that means same number of rows and columns. the second one Y is a column vector with same number of rows of X and Z. I need to create a plot between these three.The x axis will be matrix X and y axis will be vector Y. The values in Z matrix corresponding to X and Y matrix is represented in the plot and the values should show as colorbar.
Can anyone help please? I will be so grateful.
[SL: the text was formatted as code. Formatted it as text instead.]
2 Kommentare
Hank
am 10 Mär. 2020
see this thread: https://www.mathworks.com/matlabcentral/answers/5042-how-do-i-vary-color-along-a-2d-line
Akzeptierte Antwort
Piyush Lakhani
am 12 Mär. 2020
The simplest way to doing this is by using the 'surf' or 'contourf' functions.
But, for that you need to create m x n matrix for all three variables. First convert Y from column to Row and then use 'meshgrid' comand to create Y as same size as X.
Y=Y';
Y=meshgrid(Y);
Y=Y(length(X),:);
Then use countourf
contourf(X,Y,Z)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!