ODE45 to solve a 2nd order differential equation with a parameter that changes in time
Afficher commentaires plus anciens
Hello! I have been working all day to solve a relatively simple second order differential equation with a parameter that has a different value for each second, but I can't get it to work. I have looked at all questions regarding this subject, but none seem to work. How do I write down my equation or ODE45 function to incorporate the time-dependence of the heave?
function [dxdt] = pitchODE(t,x,omega_5,heave,GM0,M)
dxdt_1 = x(2);
dxdt_2 = -2*0.03*omega_5*x(2)-omega_5^2*(1-(heave(t)/(2*GM0)))*x(1)+M;
dxdt = [dxdt_1; dxdt_2];
end
My heave parameter is the height of my offshore structure at each second in time.
%Defining some parameters
time = 1:1:200; %sec
M = 1; %N/m
GM0 = 2; %m
omega_5 = 0.211; %0.22 Pitch natural freq in rad/s
heave = [ ]; %a parameter with 200 values, corresponding with the 200 seconds in time
initial_x = 0;
initial_dxdt = 0;
initial_cond = [initial_x initial_dxdt]
[t,x] = ode45(@(t,x) pitchODE(t,x,omega_5,heave,GM0,M) ,time,initial_cond)
plot(t, x(:,1))
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!