plotting simple symbolic equation

2 次查看(过去 30 天)
Sean Smith
Sean Smith 2011-11-11
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]);

回答(1 个)

bym
bym 2011-11-11
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

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by