How to plot contour map of x,y values with z as dependent variable?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Anonyms
el 16 de Ag. de 2021
Editada: Star Strider
el 16 de Ag. de 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 comentarios
Respuesta aceptada
Star Strider
el 16 de Ag. de 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 comentario
Star Strider
el 16 de Ag. de 2021
Editada: Star Strider
el 16 de Ag. de 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')
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!