Subs isn't solving for equation in symbolic representation?

David (view profile)

on 9 Oct 2013
Latest activity Commented on by David

on 10 Oct 2013

Walter Roberson (view profile)

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 ?

Walter Roberson (view profile)

on 10 Oct 2013

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.

David

David (view profile)

on 10 Oct 2013

I'm dumb. Thank you!