필터 지우기
필터 지우기

Finding X Y coordinates from surface plot

조회 수: 15 (최근 30일)
Darin
Darin 2011년 4월 20일
댓글: Ilias Iord 2017년 4월 9일
Hi All, n00b to MatLab and I have a question that is giving me fits!
peaks is a built-in example function of two variables in MatLab. You can see what peaks looks like with surf(peaks).
Using MatLab, what is the maximum value of peaks (i.e., the maximum z value)?
This one I understand. I use Z = peaks; then max (max(Z)) to get the answer. No problem!
Using MatLab, what is the x, y coordinate of the maximum value?
This is my frustrating issue!
My prof assigned this but hasn't returned a response to my email and I'd like to get this done ASAP. Any advice would be appreciated!

채택된 답변

Paulo Silva
Paulo Silva 2011년 4월 20일
[X,Y,Z] = peaks;
I=find(Z==max(max(Z)));
X(I); %x values corresponding to the points where Z is maximum
Y(I); %y values corresponding to the points where Z is maximum
To test if values are correct do
[X,Y,Z] = peaks;
surf(X,Y,Z)
hold on
I=find(Z==max(max(Z)));
plot3(X(I),Y(I),Z(I),'x')
  댓글 수: 3
Paulo Silva
Paulo Silva 2011년 4월 20일
She's just being a good teacher, by searching and trying to do the homework you always learn something.
Ilias Iord
Ilias Iord 2017년 4월 9일
This is very helpful indeed, but I am looking for one step further:
I have two vectors of co-ordinates (1-n) for X and Y and a surface (S) with n-n corresponding values.
The question is, how can I get the X, Y values for the single minimum value of S. Because S is n-n, the above solution does not work.
%calculation of drawdown in confined aquifer
clear
clc
% Parameter and variable values
xabs=3000;
yabs=xabs;
xmin=-xabs;
ymin=-yabs;
x=xmin:50:xabs;
y=ymin:50:yabs;
x1=1500;
y1=600;
x2=700;
y2=1800;
x3=1200;
y3=900;
x4=500;
y4=800;
rw=0.3; %well radius
rinf1=2000; %m radius of influence
rinf2=3000;
rinf3=5000;
rinf4=500;
k=2.58; %m/day
q1=1200; %m3/day
q2=1500;
q3=2000;
q4=500;
a=45; % m (confined aquifer width)
hw=30; %m ( well drawdown depth)
s1=drawdown(xabs,x1,y1,rinf1,k,q1,a);
s2=drawdown(xabs,x2,y2,rinf2,k,q2,a);
s3=drawdown(xabs,x3,y3,rinf3,k,q3,a);
s4=drawdown(xabs,x4,y4,rinf4,k,q4,a);
s=s1+s2+s3+s4;
"Drawdown" is the function that calculates S for the well data I need the coordinates for the minimum peak.
Thanks a lot guys!

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

추가 답변 (0개)

카테고리

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