Solving Differential Equations Symbolically and Numerically
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bailey Smith
am 26 Jan. 2019
Bearbeitet: Stephan
am 27 Jan. 2019
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)
0 Kommentare
Akzeptierte Antwort
Stephan
am 27 Jan. 2019
Bearbeitet: Stephan
am 27 Jan. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!