Effacer les filtres
Effacer les filtres

solve 12 equations with 12 unknown ERROR: FSOLVE requires all values returned by functions to be of data type double.

1 vue (au cours des 30 derniers jours)
Given the following equations in the script
function F = root12d(x)
F(1) = x(1)-x(3) == 0;
F(2) = -x(5)+x(6) == 0;
F(3) = x(7)+x(9)-4 == 0;
F(4) = x(11)+x(12)-4 == 0;
F(5) = sqrt((x(1)-x(4))^2+(x(2)-x(5))^2+(x(3)-x(6))^2)-2 == 0;
F(6) = sqrt((x(4)-x(7))^2+(x(5)-x(8))^2+(x(5)-x(9))^2)-2 == 0;
F(7) = sqrt((x(7)-x(10))^2+(x(8)-x(11))^2+(x(9)-x(12))^2)-2 == 0;
F(8) = sqrt((x(10)-x(1))^2+(x(11)-x(2))^2+(x(12)-x(3))^2)-2 == 0;
F(9)= ( (x(4)-x(1))*(x(10)-x(1))+(x(5)-x(2))*(x(11)-x(2))+(x(6)-x(3))*(x(12)-x(3)) ) / ((sqrt((x(4))-x(1))^2+(x(5)-x(2))^2+(x(6)-x(3))^2)*sqrt((x(10)-x(1))^2+(x(10)-x(2))^2+(x(12)-x(3))^2)) -cosd(90) == 0;
F(10)= ( (x(1)-x(4))*(x(7)-x(4))+(x(2)-x(5))*(x(8)-x(5))+(x(3)-x(6))*(x(9)-x(6)) ) / ((sqrt((x(1))-x(4))^2+(x(2)-x(5))^2+(x(3)-x(6))^2)*sqrt((x(7)-x(4))^2+(x(8)-x(5))^2+(x(9)-x(6))^2)) -cosd(90) == 0;
F(11)= ( (x(4)-x(7))*(x(12)-x(7))+(x(5)-x(8))*(x(11)-x(8))+(x(6)-x(9))*(x(12)-x(9)) ) / ((sqrt((x(4))-x(7))^2+(x(5)-x(8))^2+(x(6)-x(9))^2)*sqrt((x(10)-x(7))^2+(x(11)-x(8))^2+(x(12)-x(9))^2)) -cosd(90) == 0;
F(12)= ( (x(7)-x(10))*(x(1)-x(10))+(x(8)-x(11))*(x(2)-x(11))+(x(9)-x(12))*(x(3)-x(12)) ) / ((sqrt((x(7))-x(10))^2+(x(8)-x(11))^2+(x(9)-x(12))^2)*sqrt((x(1)-x(10))^2+(x(2)-x(11))^2+(x(3)-x(12))^2)) -cosd(90) == 0;
when applying
fun = @root12d;
x0 = [0,0,0,0,0,0,0,0,0,0,0,0];
x = fsolve(fun,x0)
The error message as written in title occur. How can i change the values returned by the Functions into double?

Réponse acceptée

Torsten
Torsten le 26 Mar 2018
Remove all the "== 0" strings.
Best wishes
Torsten.
  2 commentaires
Manuel Fuelling
Manuel Fuelling le 26 Mar 2018
Then a new error message occurs:
Error using trustnleqn (line 28) Objective function is returning undefined values at initial point. FSOLVE cannot continue.
Error in fsolve (line 388) trustnleqn(funfcn,x,verbosity,gradflag,options,defaultopt,f,JAC,...
Torsten
Torsten le 26 Mar 2018
Choosing x0=0 leads to a division-by-zero in the calculation of F(9),F(10),F(11) and F(12).
Best wishes
Torsten.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by