How to solve an equation with one unknown?

35 次查看(过去 30 天)
For example:
ss = (16*T*do)/pi*(do^4-di^4)
all variables are know except for (di). What is the code to solve it? Thanks in advance!
  3 个评论
Roger Stafford
Roger Stafford 2017-2-28
I like your reply, John. Pencil and paper is certainly the right way to do that problem.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-2-28
syms di
syms ss T do %or assign numeric values to the variables
Pi = sym('pi');
eqn = ss == (16*T*do)/Pi*(do^4-di^4);
sol = solve(eqn, di)
The result you get back will be a vector of four elements, reflecting the four roots of the quartic. You can use double(sol) to see the decimal versions of the exact solutions.
Depending on what you are solving, you might encounter cases where you see outputs such as
root(16*2^(1/2)*z^5 - 16*2^(1/2)*di^4*z - 17*pi, z, 1)
root(16*2^(1/2)*z^5 - 16*2^(1/2)*di^4*z - 17*pi, z, 2)
The form root(f(z), z, N) selects from the set of values, z, such that f(z) = 0 -- that is, the roots of the equation. You will sometimes even see this for cubic equations and it is not uncommon for quartic equations; most quintics and above will generate root() forms.

Community Treasure Hunt

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

Start Hunting!

Translated by