Plotting a 3D surface

2 visualizaciones (últimos 30 días)
Maria de Arizaga Barrachina
Maria de Arizaga Barrachina el 21 de Ag. de 2018
Comentada: Yuvaraj Venkataswamy el 22 de Ag. de 2018
Hello everyone, I am trying to plot a 3D surface and colouring it according to the values of a 4th variable (vector). This vector contains the values of the 4th variable for each node of the surface. For instance:
% Surface definition (9 elements, 16 *nodes*)
x = linspace(0,1,3);
y = linspace(0,1,3)';
[X,Y] = meshgrid(x,y);
Z = (X.^3) - 3*X.*(Y.^2);
% 4th dimension (temperature for each node)
T = [0, 0, 0, 0, 0, 10, 10, 10, 0, 10, 20, 20, 0, 10, 20, 30];
Other possibility would be treating the nodes as voxels and plot each voxel with its corresponding temperature color, but I have not found a way to do it either.
Thank you so much. M.

Respuestas (1)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy el 22 de Ag. de 2018
Try this,
if true
x = linspace(0,1,3);
y = linspace(0,1,3)';
[X,Y] = meshgrid(x,y);
Z = (X.^3) - 3*X.*(Y.^2);
T = [0, 0, 0, 0, 0, 10, 10, 10, 0, 10, 20, 20, 0, 10, 20, 30];
surf(X,Y,Z,T)
colorbar
end
  2 comentarios
Maria de Arizaga Barrachina
Maria de Arizaga Barrachina el 22 de Ag. de 2018
Thanks Yuvaraj! I already solved the problem. The answer is close to that, but the 4th variable has to written so its dimensions match the other variables, that would be:
T = [0, 0, 0, 0;...
0 10, 10, 10;...
0, 10, 20, 20;...
0, 10, 20, 30];
Yuvaraj Venkataswamy
Yuvaraj Venkataswamy el 22 de Ag. de 2018
Welcome

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh 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!

Translated by