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

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by David on 9 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 ?

*No products are associated with this question.*

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.

## 0 Comments