Solving non-linear equation in vector form
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, hope you are doing well.
Soi have a simple equation where the known value is a vector. So i need to get a vector as the solution.
The equation is very simple and can be easily caluclated by hand but i require it to be solved using Matlab.
Here is the code i have tried:
u2 = rand(1,1000);
syms t1
eq = t1.^2/64 == u2;
solve(eq, t1)
Any help would be appreciated, thanks.
0 commentaires
Réponse acceptée
Matt J
le 28 Avr 2021
Modifié(e) : Matt J
le 28 Avr 2021
If you have the Optimization Toolbox,
u2=[1,4,9];
opts=optimoptions('fsolve','SpecifyObjectiveGradient',true,'OptimalityTolerance',1e-12);
t1=fsolve(@(t1)objfunc(t1,u2),u2,opts)
function [err, J]=objfunc(t1,u2)
err=t1.^2/64-u2;
J=speye(numel(u2))/32; %Jacobian
end
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!