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