(Simple) How to solve basic equation

Wondering if someone can help me find the error in this simple code. I'm trying to solve for N in terms of b and bt.
sym b bt N
k = 1/24;
l = (b + 0.5)/(6 + 12*b);
m = (b^2 + b/2)/(2 + 4*b);
q = ( (-k+l+m) + bt*(-4*k+3*l+2*m) )/ (1 + 2*bt);
eqn = -1/336 - l/24 + (6/5)*l^2 + 3*m/10 + 2*m*l + (2/3)*m^2 - q/6 - bt*q/6 + (3*l*q + 2*m*q)*(1+bt) == 1/N;
s = solve(eqn, N)

 Akzeptierte Antwort

Star Strider
Star Strider am 25 Nov. 2014

0 Stimmen

In R2014b, you have to replace ‘sym’ with ‘syms’. Otherwise, all you need to do is to add collect and simplify calls to get a simplified result:
s = solve(eqn, N)
s = simplify(collect(s),'steps',10)
produces:
s =
10080/((1260*bt + 1680)*b^2 + (420*bt + 1596)*b + 35*bt + 54)

2 Kommentare

A
A am 26 Nov. 2014
This is exactly what I needed, thank you very much! Appreciate the simplify function also.
Star Strider
Star Strider am 26 Nov. 2014
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Amutha S
Amutha S am 16 Dez. 2020

0 Stimmen

sym b bt N
k = 1/24;
l = (b + 0.5)/(6 + 12*b);
m = (b^2 + b/2)/(2 + 4*b);
q = ( (-k+l+m) + bt*(-4*k+3*l+2*m) )/ (1 + 2*bt);
eqn = -1/336 - l/24 + (6/5)*l^2 + 3*m/10 + 2*m*l + (2/3)*m^2 - q/6 - bt*q/6 + (3*l*q + 2*m*q)*(1+bt) == 1/N;
s = solve(eqn, N)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

A
A
am 25 Nov. 2014

Beantwortet:

am 16 Dez. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by