Finding global minimum with rand
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ikenna Iwudike
le 2 Avr 2022
Commenté : Ikenna Iwudike
le 2 Avr 2022
I'm supposed to use the MATLAB function "rand" to generate a large number of random vectors in 3-space, with coordinates between −6 and 6. Then I have to evaluate f at those points to find the minimum. But I don't know if I'm doing it correctly. My function is f(x, y,z) = x^4 + y^4 + z^4 − 3*x^2 − 8*y^2 − 6*x*z − 4*x*y − 10*z^2 + 6*y. Here's what I have so far:
0 commentaires
Réponse acceptée
Torsten
le 2 Avr 2022
Modifié(e) : Torsten
le 2 Avr 2022
fumin = Inf;
for i = 1:100000
u = -6 + 12*rand(3,1);
fu = f(u);
if fu < fumin
umin = u;
fumin = fu;
end
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!