Borrar filtros
Borrar filtros

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

15 visualizaciones (últimos 30 días)
sung-cheol kwon
sung-cheol kwon el 19 de Dic. de 2016
Comentada: Scout Patel el 15 de Ag. de 2022
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 comentarios
José-Luis
José-Luis el 19 de Dic. de 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
Scout Patel el 15 de Ag. de 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

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 19 de Dic. de 2016
Editada: Walter Roberson el 19 de Dic. de 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.

Dean Culver
Dean Culver el 29 de Mzo. de 2018
Editada: Dean Culver el 29 de Mzo. de 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

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by