How to find a local maximum in surf (3D) plot ?
6 ビュー (過去 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
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
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
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.
0 件のコメント
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!