How to find max and min of fuction of 2 independent variables?
Mostrar comentarios más antiguos
My question is how can I find minimum and maximum of this function, and then tag them with 'o' in function graph?

This is my code so far:
function funkcija(intervalpox,intervalpoy,korak,crtanje)
x=0:korak:intervalpox;
y=0:korak:intervalpoy;
[X,Y] = meshgrid(x,y);
Z = (sin(sqrt(X.^2 + Y.^2)) ./ (sqrt(X.^2 + Y.^2)));
mesh(X,Y,Z)
grid on
xlabel('.x.')
ylabel('.y.')
zlabel('.z.')
title('mesh')
8 comentarios
Walter Roberson
el 20 de Feb. de 2019
max() and min() can have two outputs instead of 1...
Faris Hajdarpasic
el 20 de Feb. de 2019
Walter Roberson
el 20 de Feb. de 2019
[~, location_of_max] = max(Z(:));
[~, location_of_min] = min(Z(:));
x_at_max = X(location_of_max);
y_at_max = Y(location_of_max);
x_at_min = X(location_of_min);
y_at_min = Y(location_of_min);
plot(x_at_max, y_at_max, 'go', x_at_min, y_at_min, 'r+');
Faris Hajdarpasic
el 20 de Feb. de 2019
Walter Roberson
el 20 de Feb. de 2019
[ThisOutputWillNeverBeUsed, location_of_max] = max(Z(:));
clear ThisOutputWillNeverBeUsed
[ThisOutputWillNeverBeUsedEither, location_of_min] = min(Z(:));
clear ThisOutputWillNeverBeUsedEither
x_at_max = ... and so on
Faris Hajdarpasic
el 20 de Feb. de 2019
Faris Hajdarpasic
el 20 de Feb. de 2019
Editada: Faris Hajdarpasic
el 20 de Feb. de 2019
Walter Roberson
el 21 de Feb. de 2019
[~, location_of_max] = max(Z(:));
[~, location_of_min] = min(Z(:));
x_at_max = X(location_of_max);
y_at_max = Y(location_of_max);
z_at_max = Z(location_of_max);
x_at_min = X(location_of_min);
y_at_min = Y(location_of_min);
z_at_min = Z(location_of_min)
plot3(x_at_max, y_at_max, z_at_max, 'go', x_at_min, y_at_min, z_at_min,'r+');
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Line Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
