How to transfer surf(x,y,z) to a data contains height value?

조회 수: 3 (최근 30일)
Yu Zou
Yu Zou 2018년 1월 18일
답변: Walter Roberson 2018년 1월 19일
Greeting everyone!
What i have now is 3 Matrix x,y,z, which can be presented by surf(x,y,z).
But i want to transfer these data to one matrix containing height value, which can be presented by surf(f).
Thanks!
Here is my data:
[x,y,z] = sphere; % Makes a 21-by-21 point sphere
x = x(11:end,:); % Keep top 11 x points
y = y(11:end,:); % Keep top 11 y points
z = z(11:end,:); % Keep top 11 z points
r = 3; % r radius value
x=r*x+r;
y=r*y+r; % Move x, y starting from 0
z=r*z; % Change the radius of the dom to r
% so i generate a dom(half ball) with radius 3
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 1월 18일
surf(f) is the same as surf(1:size(f,1), 1:size(f,2), f) so the only way to get this to work would be to interpolate or extrapolate values at unit intervals so that the tick labels line up with the data values.
This would not seem to be a useful thing to do. If you have the coordinates of the data points available, then use them.
Yu Zou
Yu Zou 2018년 1월 19일
thanks for advice. I want to extract the height from a dom so that i can execute something else, so it's pretty useful for me.

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

답변 (2개)

Image Analyst
Image Analyst 2018년 1월 18일
Try interp2() to take your coordinates and make a 2-D matrix where the values are the z values.
  댓글 수: 3
Image Analyst
Image Analyst 2018년 1월 19일
Not sure since I don't have any data to try. You forgot to attach your data. Make it easy for people to help you, not hard, by attaching your data.
Yu Zou
Yu Zou 2018년 1월 19일
Thanks for advice, i've attached my code

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


Walter Roberson
Walter Roberson 2018년 1월 19일
F = scatteredInterpolant(x(:),y(:),z(:));
[X,Y] = ndgrid(1:floor(max(x(:))));
Z = F(X,Y);
surf(Z)
You will find this rather unsatisfactory, but it is the best that can be done while maintaining the axes labels with a simple surf(Z)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by