Solving Differential Equations Symbolically and Numerically

1 次查看(过去 30 天)
I am having some trouble setting up a differential equation to be solved using MATLAB:
I am solving for v(t) and have values for m, J, R, θ, and b, but I would like to solve it symbolically first, and then go back and solve it numerically.
To solve numerically, I would use an ode sover, correct?
Any help or pointers is appreciated!
My attempt (which I fear is very wrong):
syms v(t) x_dot x_dbl_dot m J R theta b g x
a=x_dbl_dot;
alpha=x_dbl_dot/R;
eqn=diff(x,t,2)==(J+2*m*R^2);
eqn1=diff(x,t)==(b*R^2)-m*g*R^2*sin(theta);
cond=[v(t)==0];
xSol(t)=dsolve(eqn,eqn1,cond)

采纳的回答

Stephan
Stephan 2019-1-27
编辑:Stephan 2019-1-27
Hi,
why do you have the 2.derivative in your code? I do only find the first derivative in your attached equation. Also i think your code is already describing v(t) since you can isolate xdot. So you already have the solution for v(t).
What you can do is solve for x(t) with the condtion x(0) == 0 - not v(0):
syms x(t) b R m a g theta J alpha
% The equation like you posted it
eqn = -b*diff(x,t)*R - m*a*R + m*g*(R*sin(theta)) == (J + R^2)*alpha;
% The isolated term for v(t):
eqn = isolate(eqn, diff(x,t));
% The solution of the ode:
xSol(t) = x == dsolve(eqn,x(0)==0);
% Write the results pretty:
pretty(eqn)
pretty(xSol)
That should be what you wanted to do:
2
d alpha (R + J) + R a m - R g m sin(theta)
-- x(t) == - -----------------------------------------
dt R b
2
t (J alpha + R alpha + R a m - R g m sin(theta))
x(t) == - -------------------------------------------------
R b
Best regards
Stephan

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by