Borrar filtros
Borrar filtros

Locating max/min of 3d surface

5 visualizaciones (últimos 30 días)
Jared
Jared el 27 de Nov. de 2011
How could I go about locating the global min/max of a user input function. The GUI plots a function based on user input:
% Get the function
g=get(handles.funcxy,'String');
% Get the x limits
limit=[str2num(char(get(handles.xmin,'String'))),... str2num(char(get(handles.xmax,'String')))];
% Convert to inline for plotting
func=inline(char(g));
% Set axes to draw on
axes(handles.plot);
% Plot the surface defined by a function f(x,y)=func
ezsurf(func,limit);
I have figured out in order to find the z maximum I can do
sh=ezsurf(func,limit);
setappdata(0, 'function', char(g));
zd=get(sh,'zdata');
zmax=max(max(zd));
But how can I get the corresponding x,y points

Respuesta aceptada

Jared
Jared el 27 de Nov. de 2011
I found the answer myself so I figured I might as well post the solution for anyone else.
sh=ezsurf(func,limit);
zd=get(sh,'zdata');
xd=get(sh,'xdata');
yd=get(sh,'ydata');
% Construct 3xa matrix of data points (X,Y,Zmax)
while a<=size(i,1)
A(1,a)=xd(i(a));
A(2,a)=yd(i(a));
A(3,a)=zmax;
a=a+1;
end
  1 comentario
Walter Roberson
Walter Roberson el 28 de Nov. de 2011
You do not calculate zmax within that code ?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by