How to find max and min of fuction of 2 independent variables?
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 20 Feb. 2019
max() and min() can have two outputs instead of 1...
Faris Hajdarpasic
am 20 Feb. 2019
Walter Roberson
am 20 Feb. 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
am 20 Feb. 2019
Walter Roberson
am 20 Feb. 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
am 20 Feb. 2019
Faris Hajdarpasic
am 20 Feb. 2019
Bearbeitet: Faris Hajdarpasic
am 20 Feb. 2019
Walter Roberson
am 21 Feb. 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+');
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Point Cloud Processing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
