Plot 2d colored image on a 3d space

4 visualizaciones (últimos 30 días)
James Mathio
James Mathio el 21 de Ag. de 2021
Respondida: Walter Roberson el 21 de Ag. de 2021
I have a set of .xyz data files where x and y are cooredinates and z is the value given to each coordinate (resistivity). Using the surf function as the code below dipicts I am able to see a 3d colored image of the resistivity at each location. Using view (30,90) I can see it's projection onto 2d space. However, what I want is slightly different than what view outputs. We know in reality to each (X,Y) coordinate a certain height can be associated. So I want the 2d colored output of view to be plotted on a 3d space where the z axis indicates the variable height, and not the colorbar. How to do this?
%b is a M by 3 matrix
x=b(:,1);
y=b(:,2);
z=b(:,3);
N = 250;
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[X, Y] = ndgrid(xvec, yvec);
F = scatteredInterpolant(x, y, z);
Z = F(X, Y);
surf(X, Y, Z, 'edgecolor', 'none');
colormap default
colorbar
%view(0,90)
  2 comentarios
Walter Roberson
Walter Roberson el 21 de Ag. de 2021
When you use that code, the Z axis is going to indicate the height.
The output is also going to be colored, with the range of Z values divided by the number of entries in the colormap and the color index being proportionate to the fraction of the Z range.
If you do not want the output to be colored that way, then use a different colormap, such as
colormap gray
James Mathio
James Mathio el 21 de Ag. de 2021
To every coordinate (X,Y,Z) a certain value is associated. I mean I have a 3d coordinate space and to each coordinate I have given a certain value R (resistivity). I can view this as a 2d space containing (X,Y) points with a certain Z and R. So basically my question is if I want to use surf function it gives me a 3d colored image, where X and Y axes are coordinates and Z axis indicates the values R. So with that image I cannot show the third coordinate point of the (X,Y,Z) data points, and only X and Y are shown. So the Z coordinate is not shown in the output. Do you get the question?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Ag. de 2021

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by