Solve issue in Matlab R2018b

조회 수: 2 (최근 30일)
John Jarvis
John Jarvis 2019년 3월 28일
댓글: Star Strider 2019년 3월 28일
I was using Matlab R2014a earlier where I was able to solve this equation easily, but in Matlab R2018b it is returning the
error in sol = solve(eqn,a,[0 pi]); I couldn't figure out why. The working code in Matlab 2014a is
syms a T
v2=-2.3750
g=1;
b=0;
e2=0.5;
k=2.5;
w=-2*cos(k);
eqn = sin(3*k+a)./sin(2*k+a)==v2-w+(g.*T.^2)+(e2.*T.^2.*sin(k)^2)./(sin(2*k+a)^2+b*T.^2*sin(k).^2);
sol = solve(eqn,a,[0 pi]);
digits(5)
solutions = vpa(subs(sol),3)
Please note that "a" is to be bound to take values between 0 and pi.
  댓글 수: 3
madhan ravi
madhan ravi 2019년 3월 28일
Only you can specify the range in vpasolve() where only one parameter is not known but with solve you can't specify the bounds.
John Jarvis
John Jarvis 2019년 3월 28일
편집: John Jarvis 2019년 3월 28일
@Image Analyst:
The exact errors are as follows (all the red text)
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in SolutionsPlot (line 11)
sol = solve(eqn,a,[0 pi]);

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

채택된 답변

Star Strider
Star Strider 2019년 3월 28일
Restrict ‘a’ using an assume call.
Try this:
syms a T
assume(a >= 0 & a <= pi)
v2=-2.3750
g=1;
b=0;
e2=0.5;
k=2.5;
w=-2*cos(k);
eqn = sin(3*k+a)./sin(2*k+a)==v2-w+(g.*T.^2)+(e2.*T.^2.*sin(k)^2)./(sin(2*k+a)^2+b*T.^2*sin(k).^2);
[sol,prms,conds] = solve(eqn,a, 'ReturnConditions',true)
digits(5)
solutions = vpa(subs(sol),3)
vpaconds = vpa(conds)
  댓글 수: 4
John Jarvis
John Jarvis 2019년 3월 28일
@Star Strider, Many thanks for your elaboration.
Star Strider
Star Strider 2019년 3월 28일
As always, my pleasure.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by