fsolve for a set of equations

2 vues (au cours des 30 derniers jours)
Ann
Ann le 8 Avr 2020
Commenté : Torsten le 8 Avr 2020
Hi,
I have a trouble solving this set of equations:
syms E
f1 = (-j*(sqrt(((2*mb)./h_.^2)*(E - V0) - k_I(i).^2))/mb) - ((sqrt(((2*mw./h_.^2)*E) - k_I(i).^2))/mw)*tan(0.5*(sqrt(((2*mw./h_.^2)*E) - k_I(i).^2))*a);
f2 = (-j*(sqrt(((2*mb)./h_.^2)*(E - V0) - k_I(i).^2))/mb) + ((sqrt(((2*mw./h_.^2)*E) - k_I(i).^2))/mw)*cot(0.5*(sqrt(((2*mw./h_.^2)*E) - k_I(i).^2))*a);
F = @(E) [f1; f2];
x0 = [10;10];
[F, fval] = fsolve(F, x0)
I get an error 'FSOLVE requires all values returned by functions to be of data type double.'. How can I correct the code? And what's the best way to solve such set of equations?
Thank you for any help provided to that issue.
Kind regards,
Ann

Réponses (1)

darova
darova le 8 Avr 2020
Try this
syms x
a = 1;
b = 2;
f = a*x+b;
F = matlabFunction(f);
fsolve(F,1)
  1 commentaire
Torsten
Torsten le 8 Avr 2020
Or just remove the line
syms E

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by