Mass Spring System ode45 with multiple damping values
Mostrar comentarios más antiguos
I am working on this problem where I have to model multiple mass spring systems that all have different damping values. My model uses the equation of
with the initial conditions of m = 5 kg, k = 0.5 N/m, and
. I converted this ODE into a system of 1st order ODEs so I could use ode45. I need to model the above equation for when
(overdamped) ,
(critcally damped), and
(underdamped). I am confused on how I could be able to specify the different damping conditions with ode45, I was thinking to use it within a for loop for each value c but I am having errors occur within my ode45 function. Any help would be greatly appreciated.
% Constants
m = 5; % kg
k = 0.5; % N/m
c = [0 , sqrt(4*m*k)-1 , sqrt(4*m*k)+1, sqrt(4*m*k)]; % damping constants
A = 1.00002;
B = 3.16228;
w0 = sqrt(k/m);
t = 20;
% Function
% Let
% u1 = y ---> u1' = y' = u2
% u2 = y' ---> u2' = 1/m*(-k*u1-c*u2)
f = @(t,u) [u(2) ; 1/m*(-k*u(1)-c*u(2))];
fA = @(t) A*cos(w0*t)+B*sin(w0*t);
% IC
u0 = [1 1];
tspan = [0 t];
% Solve
for tspan = [0 t]
[t,u] = ode45(f,tspan,u0);
if abs(c^2) > 4*m*k
plot(t,u(:,1))
end
end
1 comentario
KSSV
el 22 de Feb. de 2022
You can change C here in a loop and get the equation solved.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

