How to plot contour map of x,y values with z as dependent variable?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anonyms
am 16 Aug. 2021
Bearbeitet: Star Strider
am 16 Aug. 2021
I have this data where my Z is is the dependent variable for corresponding x and y. I need to import the data from excel and plot a contour color map
Can someone help please?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/713502/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/713502/image.png)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 16 Aug. 2021
If ‘M’ is the matrix in the image:
y = M(1,:)
x = M(:,1)
z = M(2:end, 2:end);
So for example:
M = [NaN 1 2 3 4 5; 10 rand(1,5); 11 rand(1,5); 12 rand(1,5); 13 rand(1,5); 14 rand(1,5)]
y = M(1,2:end)
x = M(2:end,1)
z = M(2:end, 2:end)
figure
contourf(x, y, z)
.
1 Kommentar
Star Strider
am 16 Aug. 2021
Bearbeitet: Star Strider
am 16 Aug. 2021
My pleasure.
The matrix does not have to be square. However, the lengths of the vectors of ‘x’ and ‘y’ have to match the size of the matrix.
However, if you want me to help you with it, you need to provide it in a form I can works with. My version of MATLAB cannot run images of code or data, only the actual code or data.
EDIT — (16 Aug 2021 at 21:06)
Same idea, however with non-square matrix —
M = [NaN 1 2 3 4 5; 10 rand(1,5); 11 rand(1,5); 12 rand(1,5); 13 rand(1,5); 14 rand(1,5); 15 rand(1,5)]
y = M(1,2:end)
x = M(2:end,1)
z = M(2:end, 2:end)
figure
contourf(x, y, z.')
xlabel('x')
ylabel('y')
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution 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!