How to display minimum vaue of a Surface z-axis.

조회 수: 6 (최근 30일)
Afz
Afz 2012년 12월 20일
I have drew a trisurf with 100 values in each x,y and z variable, and I want to display the least 10 data values of z on the surface over the location of the points .

답변 (2개)

Image Analyst
Image Analyst 2012년 12월 21일
편집: Image Analyst 2012년 12월 21일
sortedValues = sort(z(:), 'ascend');
fprintf('%f\n', sortedValues(1:10));
Use text() if you want to display some message above the data point.
  댓글 수: 1
Image Analyst
Image Analyst 2012년 12월 21일
편집: Image Analyst 2012년 12월 21일
I noticed your attempt at using text below:
text(Xmin+xgap, Ymin+ygap, Zmin+zgap);
like I suggested, but where is the message you want to display? You didn't supply it. Try creating a message like I said:
message = sprintf('Zmin=%.2f', Zmin); % Create string for the Zmin point.
text(Xmin+xgap, Ymin+ygap, Zmin+zgap, message);

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


Matt Kindig
Matt Kindig 2012년 12월 21일
편집: Matt Kindig 2012년 12월 21일
You can do this using text() function. Something like this:
%Xval, Yval, and Zval are your MxN matrices used to make the surface.
Zmin = sort(Zval(:), 'descend'); %sort z decreasing
Zmin = Zmin(1:10); %10 smallest z values
pos = ismember(Zval, Zmin); %location of Z values
Xmin = reshape(Xval(pos),[],1);
Ymin = reshape(Yval(pos),[],1);
xgap = 1; ygap = 1; zgap = 1; %adjust to get desired spacing of label from point.
text( Xmin+xgap, Ymin+ygap, Zmin+zgap);
  댓글 수: 2
Matt Kindig
Matt Kindig 2012년 12월 21일
편집: Matt Kindig 2012년 12월 21일
Or maybe I misunderstood your question. Are you asking how to plot these points? In that case, just use plot3():
hold on;
plot3( Xmin, Ymin, Zmin, 'o');
Afz
Afz 2012년 12월 21일
I just want the numeric values used to plot the surface be printed over those z points. Data labels of z over each point. I used your code it gives following error.
??? Error using ==> text String argument expected after 2 or 3 numeric arguments
Error in ==> FILENAME at 23 text(Xmin+xgap, Ymin+ygap, Zmin+zgap);
I am using this code
if true
holdState = ishold;
Xval = xlsread('a.xlsx',1,'A1:CV1');
%Defining y
Yval = xlsread('a.xlsx',1,'A2:CV2');
%Defining z
Zval = xlsread('a.xlsx',1,'A3:CV3');
tri = delaunay(Xval,Yval);
h1 = trisurf(tri, Xval, Yval, Zval);
set(h1, 'FaceColor', 'g')
xlabel('Granular Rutting B4');
ylabel('Fine Rutting B5');
zlabel('RSS');
hold on;
iamlegend = legend('1');
Zmin = sort(Zval(:), 'descend'); %sort z decreasing % code
Zmin = Zmin(1:10); %10 smallest z values
pos = ismember(Zval, Zmin); %location of Z values
Xmin = reshape(Xval(pos),[],1);
Ymin = reshape(Yval(pos),[],1);
xgap = 1; ygap = 1; zgap = 1; %adjust to get desired spacing of label from point.
text(Xmin+xgap, Ymin+ygap, Zmin+zgap);
if ~holdState,
hold off;
end

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by