Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Subs isn't solving for equation in symbolic representation?

Asked by David on 9 Oct 2013
Latest activity Commented on by David on 10 Oct 2013

Hi, I've tried to do this for a long time but can't figure out how to solve it. Here's my code so far.

if true
  % code
syms V H r Pi;
eq = sym('Pi*r^2* H + 2/3*Pi*r^3 =1050');
simpleeq = simple(eq)
tempeq = subs(simpleeq, {V, H, Pi}, {v, h, pi})
end

So usually subs takes in the value and substitutes it to get you one term, but in the end I get: (2*pi*r^3)/3 + 10*pi*r^2 = 1050

which doesn't solve for r.

How do I exactly do this ?

0 Comments

David

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 10 Oct 2013
Accepted answer

You never asked it to solve for r. subs() does a substitution, not try to find a solution. You need to use solve() to find solutions.

T = solve(simpleeq, r);
tempeq = subs(T, {V, H, Pi}, {v, h, pi});

and you will probably want to double(tempeq) before you use it.

1 Comment

David on 10 Oct 2013

I'm dumb. Thank you!

Walter Roberson

Contact us