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

조회 수: 2 (최근 30일)
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?

채택된 답변

Torsten
Torsten 2018년 3월 26일
Remove all the "== 0" strings.
Best wishes
Torsten.
  댓글 수: 2
Manuel Fuelling
Manuel Fuelling 2018년 3월 26일
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 2018년 3월 26일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by