solve not outputting an answer

조회 수: 2 (최근 30일)
ben howey
ben howey 2017년 3월 20일
댓글: Walter Roberson 2017년 3월 21일
I am trying to solve 6 non linear equation with 6 unknowns using the symbolic method. When I run the following script, it just stays on busy and does not return any values. Can anyone help?!
lAB=0.35;
lBC=0.257;
lCD=0.995;
dX=1.4;
dz=0.5;
Mmw=0.5;
rhomw=11340;
Mmb=0.116E-3;
rhomb=14;
Fmw=Mmw*9.81;
Fmb=Mmb*9.81;
syms T1 T2 T3 a1 a2 a3
sol=solve([T1*cos(a1)-T2*cos(a2)==0,...
T2*cos(a2)-T3*cos(a3)==0,T1*sin(a1)+T2*sin(a2)-Fmw==0,...
Fmb-T2*sin(a2)-T3*sin(a3)==0,lAB*cos(a1)+lBC*cos(a2)+lCD*cos(a3)==dX,...
lAB*sin(a1)+lBC*sin(a2)+lCD*sin(a3)==dz],[T1,T2,T3,a1,a2,a3]);
Thanks
  댓글 수: 1
ben howey
ben howey 2017년 3월 20일
편집: Walter Roberson 2017년 3월 20일
I have also tried using the numerical solver fsolve as follows and it returns an error and won't run at all.
function F = angsystem(x,lAB,lBC,lCD,dX,dz,Fmw,Fmb)
F(1)=x(1)*cos(x(2))-x(3)*cos(x(4));
F(2)=x(3)*cos(x(4))-x(5)*cos(x(6));
F(3)=x(1)*sin(x(2))+x(3)*sin(x(4))-Fmw;
F(4)=Fmb-x(3)*sin(x(4))-x(5)*sin(x(6));
F(5)=lAB*cos(x(2))+lBC*cos(x(4))+lCD*cos(x(6))-dX;
F(6)=lAB*sin(x(2))+lBC*sin(x(4))+lCD*sin(x(6))-dz;
%%%%%%%.m Script
lAB=0.35;
lBC=0.257;
lCD=0.995;
dX=1.4;
dz=0.5;
Mmw=0.5;
rhomw=11340;
Mmb=0.116E-3;
rhomb=14;
Fmw=Mmw*9.81;
Fmb=Mmb*9.81;
fun=@angsystem;
x0=[20,20,20,0,0,0];
x=fsolve(fun,x0)

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 3월 20일
%%%%%%%.m Script
lAB=0.35;
lBC=0.257;
lCD=0.995;
dX=1.4;
dz=0.5;
Mmw=0.5;
rhomw=11340;
Mmb=0.116E-3;
rhomb=14;
Fmw=Mmw*9.81;
Fmb=Mmb*9.81;
fun=@(x) angsystem(x,lAB,lBC,lCD,dX,dz,Fmw,Fmb);
x0=[20,20,20,0,0,0];
[x, fval] = fsolve(fun,x0)
  댓글 수: 2
ben howey
ben howey 2017년 3월 20일
Thanks so much. Just for my knowledge....why does the @(x) angsystem(x,lAB...) have to be separated?
Also the return of the angles (x([2,4,6]) are in radians correct?
Thanks Ben
Walter Roberson
Walter Roberson 2017년 3월 21일
The @(x) etc. does not need to be separated. I made the minimum change to your existing code which already separated it. You had
fun = @angsystem;
before.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by