How to plot contour map of x,y values with z as dependent variable?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Anonyms
il 16 Ago 2021
Modificato: Star Strider
il 16 Ago 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?
0 Commenti
Risposta accettata
Star Strider
il 16 Ago 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 Commento
Star Strider
il 16 Ago 2021
Modificato: Star Strider
il 16 Ago 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')
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Distribution Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!