MATLAB Answers


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})

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 ?


Log in to comment.

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

Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today