Symbolic toolbox help using solve command

3 views (last 30 days)
I have the following simple code and Im not sure how else to solve it for more than one equation, the variable hl and hr can change at any time so I want matlab to automatically solve for the different equation im assuming its something simple that i have missed, thanks in advance kyle
hl = 1;
hr = 0.1;
g=9.81;
syms s
geneqn = s*((s - ((g*hr)/(4*s))*(1+(sqrt(1+((8*s^2)/(g*hr)))))) + 2*(sqrt(((g*hr)/2)*(sqrt(1+((8*s^2)/(g*hr)))-1))) - 2*sqrt(g*hl));
S = solve('geneqn=0')
s=0 << %I know that this is not correct

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 12 Mar 2012
hl = 1; hr = 0.1; g=9.81;
syms s
geneqn = s*((s - ((g*hr)/(4*s))*(1+(sqrt(1+((8*s^2)/(g*hr))))))...
+ 2*(sqrt(((g*hr)/2)*(sqrt(1+((8*s^2)/(g*hr)))-1))) - 2*sqrt(g*hl));
out = solve(geneqn,s)
on my PC:
  1 Comment
kyle lyth
kyle lyth on 12 Mar 2012
thank you for the quick response, i didn't realise it would solve for zero automatically :) thanks again kyle

Sign in to comment.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!