changing expression to function and then optimize the function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
for the follwing expresson:
expr = expr + w(r2) * (sqrt((x(r1)-a(i))^2 + (y(r1)-b(i))^2)) - w(r1) * (sqrt((x(r2)-a(i))^2 + (y(r2)-b(i))^2));
I converted it to function by
syms expr x y w
ht = matlabFunction(expr);
Please suggest hw to minimize the above expression to find the values of multiple values of x,y and w.
I have data for the variable a,b,r1 and r2
0 commentaires
Réponses (1)
Matt J
le 15 Jan 2024
Modifié(e) : Matt J
le 15 Jan 2024
Do not use syms or matlabFunction for a situation like this. Just write a plain function to compute the expression,
function expr=ht(xyw, a,b,r1,r2)
x=xyw(1);
y=xyw(2);
w=xyw(3)
expr=...
end
and then optimize it with, for example,
x0=... %initial guesses
y0=...
w0=...
xyw=fminunc(@(xyw) ht(xyw, a,b,r1,r2) , [x0,y0,w0])
2 commentaires
Voir également
Catégories
En savoir plus sur Optimization 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!