Plot 2d colored image on a 3d space

조회 수: 2 (최근 30일)
James Mathio
James Mathio 2021년 8월 21일
답변: Walter Roberson 2021년 8월 21일
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
Walter Roberson
Walter Roberson 2021년 8월 21일
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 2021년 8월 21일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 8월 21일

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by