Solving Differential Equations Symbolically and Numerically

조회 수: 1 (최근 30일)
Bailey Smith
Bailey Smith 2019년 1월 26일
편집: Stephan 2019년 1월 27일
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