plotting simple symbolic equation

3 views (last 30 days)
Sean Smith
Sean Smith on 11 Nov 2011
I'm new to using symbolic equations and variables. I am trying to plot this symbolic equation but I keep getting an error saying Maximum recursion limit of 500 reached. also when I type h into matlab to see the equation it shows the first value -0.12 as - 0.12000000000080035533756017684937 I don't get why it does this and it just does it to that coefficient. And the g value has an obnoxious amount of decimal places and I'm using format short. It's a trajectory equation, so g is when the ball hits the ground.
syms t
h=sym('-0.12*t^4+12*t^3-380*t^2+4100*t+220');
g=solve('-0.12*t^4+12*t^3-380*t^2+4100*t+220=0');
g=g(2) %only answer that makes sense
figure; ezplot(h,[0,g]);

Answers (1)

bym
bym on 11 Nov 2011
where to begin...
first since you have declared t to be symbolic, you can define your equation to be
eq = -0.12*t^4+12*t^3-380*t^2+4100*t+220 % no quotes
sol = solve(eq) % solve the equation matlab assumes it's =0
vsol = vpa(sol,5) % takes care of your 'obnoxious' decimal places
ezplot(char(eq),[0 max]) % plot function - note conversion of symbolic to character

Categories

Find more on Mathematics 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!