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

6 ビュー (過去 30 日間)
sung-cheol kwon
sung-cheol kwon 2016 年 12 月 19 日
コメント済み: Scout Patel 2022 年 8 月 15 日
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 Center および File ExchangeCurve Fitting Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by