Effacer les filtres
Effacer les filtres

How to solve an equation with one unknown?

35 vues (au cours des 30 derniers jours)
Ahmad Ghareeb
Ahmad Ghareeb le 28 Fév 2017
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 commentaires
Roger Stafford
Roger Stafford le 28 Fév 2017
I like your reply, John. Pencil and paper is certainly the right way to do that problem.
Ahmad Ghareeb
Ahmad Ghareeb le 28 Fév 2017
This is just an example.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 28 Fév 2017
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