How to find a local maximum in surf (3D) plot ?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
José-Luis
am 19 Dez. 2016
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
am 15 Aug. 2022
[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
Antworten (2)
Walter Roberson
am 19 Dez. 2016
Bearbeitet: Walter Roberson
am 19 Dez. 2016
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 Kommentare
Dean Culver
am 29 Mär. 2018
Bearbeitet: Dean Culver
am 29 Mär. 2018
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 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!