How to plot an array of 4 columns?

5 visualizaciones (últimos 30 días)
Pierre
Pierre el 5 de Dic. de 2024
Comentada: Star Strider el 5 de Dic. de 2024
Hello,
I have an array of four columns: X,Y,Z,A.
I need to visualize this data.
I tried surf3 and plot3 but it seems that the data I have is not in the right format for this function.
I suspect A is going to be a color, but I am not sure how to do it
Thanks
  2 comentarios
Stephen23
Stephen23 el 5 de Dic. de 2024
Is the data gridded or scattered?
Torsten
Torsten el 5 de Dic. de 2024
Editada: Torsten el 5 de Dic. de 2024
Use "slice"
after you made them gridded.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 5 de Dic. de 2024
I wrote this to solve a similar problem. The original problem was to create a surf plot to match a scatter plot.
Try this —
N1 = 100;
x = randn(N1,1);
y = randn(N1,1);
z = randn(N1,1);
c = 10*rand(size(z));
figure
stem3(x, y, z)
hold on
scatter3(x, y, z, 100, c, 'filled')
hold off
CL = clim;
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('Z')
Zfcn = scatteredInterpolant(x, y, z, 'natural','none');
Cfcn = scatteredInterpolant(x, y, c, 'natural','none');
N = 150;
xv = linspace(min(x), max(x), N);
yv = linspace(min(y), max(y), N);
[Xm,Ym] = ndgrid(xv, yv);
Zm = Zfcn(Xm, Ym);
Cm = Cfcn(Xm, Ym);
figure
surfc(Xm, Ym, Zm, Cm, 'EdgeColor','interp')
clim(CL)
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('Z')
The apparently random colours match in both.
.
  2 comentarios
Pierre
Pierre el 5 de Dic. de 2024
great, thank you, will try
Star Strider
Star Strider el 5 de Dic. de 2024
My pleasure!
Please follow up with results, and consider uploading your data here (use the ‘paperclip’ icon in the top toolstrip).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by