I need to solve for the one variable (sw) and get a numerical answer for it. All other variables are known but I am trying to keep a generalized code. I think I might be using the wrong function. Please help!

조회 수: 1 (최근 30일)
syms sw
tc=0.058;
ka=0.87;
M=.85;
CL=.75;
eqns=((ka/(cos(sw)))-(tc/(cos(sw).^2))-(CL/(10*cos(sw).^3)))==M;
solsw=solve(eqns,sw);

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 10일
solsw = solve(eqns, sw, 'maxdegree', 3);
sort(double(solsw))
6 solutions, one of which is negative.
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 2월 10일
"'MaxDegree' — Maximum degree of polynomial equations for which solver uses explicit formulas
Maximum degree of polynomial equations for which solver uses explicit formulas, specified as a positive integer smaller than 5. The solver does not use explicit formulas that involve radicals when solving polynomial equations of a degree larger than the specified value."
That is, your previous code was not wrong -- but you are defining something that is at least a cubic polynomial because of the cos^3 . There are explicit representations known for cubics and quartics, but they are long, and most of the time writing them out explicitly just gets in the way of understanding the equation. So for anything over degree 2, most of the time MATLAB puts in a placeholder root() function instead of expanding out the solution.
In the symbolic toolbox, root(expression in z,z) stands in for "the set of values of z such that the expression becomes 0" -- that is, for the roots of the given equation. The symbolic toolbox knows how to manipulate those root() placeholders appropriately.
However, left to itself, sometimes the symbolic toolbox only outputs one root; if you ask for a MaxDegree of 3 or 4 and the expression can be written out explicitly with that, then it will list all of the roots by their formulas, allowing you to ask for specific numeric values for all of the possibilities.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by