How to find max and min of fuction of 2 independent variables?
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 20 Fév 2019
max() and min() can have two outputs instead of 1...
Faris Hajdarpasic
le 20 Fév 2019
Walter Roberson
le 20 Fév 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
le 20 Fév 2019
Walter Roberson
le 20 Fév 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
le 20 Fév 2019
Faris Hajdarpasic
le 20 Fév 2019
Modifié(e) : Faris Hajdarpasic
le 20 Fév 2019
Walter Roberson
le 21 Fév 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+');
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Point Cloud Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
