How to find a local maximum in surf (3D) plot ?

20 次查看(过去 30 天)
I would like to find a local maximum in 3D surf plot and to draw the identified maximum as a line To further understand what i want to do, i drew a black line by my hand as shown in attached figure,
How could i do this?
  3 个评论
José-Luis
José-Luis 2016-12-19
To me this looks like a catchment delineation problem. You could start with a flow accumulation and follow all the cells that have an accumulation of one and are not on the border.
Scout Patel
Scout Patel 2022-8-15
[TF1,P] = islocalmax(Array,2,'MinProminence',4);%theshold at 4...change accordingly
P(TF1)
V1 = find(TF1, 3, 'first');%this finds the first 3...change accordingly
[y1,x1]=ind2sub(size(Array),V1)
% Fit line to data using polyfit
c = polyfit(x1,y1,1);
% Display evaluated equation y = m*x + b
disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))])
% Evaluate fit equation using polyval
y_est = polyval(c,x1);
% Add trend line to plot
hold on
plot(x1,y_est,'r--','LineWidth',0.5)
hold off

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2016-12-19
编辑:Walter Roberson 2016-12-19
You can also proceed by taking max() along a dimension of your data. There are a couple of problems you would need to work out with that:
A) The line you are interested in might not cross the entire array, but max() is going to find a maximum for every row or column anyhow
B) The line you are interested in might happen to travel sharply in the direction along which you are taking the max; you would only get one location per row or column, whereas if you had happened to ask along the other dimension you would have gotten a nice answer.

Dean Culver
Dean Culver 2018-3-29
编辑:Dean Culver 2018-3-29
This would be computationally inefficient, but I think it would get the job done:
  • Determine the maximum value of the surface function z on the perimeter. Call it z_(p,max).
  • Determine the row and column indices (i,j) such that z(i,j)=z_(p,max).
  • Record x(i,j) and y(i,j)
  • (begin loop) Sample the points immediately adjacent to the current (i,j).
  • Choose the maximum of these which is not a previously recorded value.
  • Record the new (i,j), x(i,j), y(i,j), and z(i,j).
  • (end loop when you've reached a perimeter and can no longer proceed)
  • plot3 to get the curve

类别

Help CenterFile Exchange 中查找有关 Curve Fitting Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by