Problem Solving Kinematic ODE with Forcing Function

1 visualización (últimos 30 días)
Martelizer
Martelizer el 27 de Oct. de 2020
Comentada: Martelizer el 27 de Oct. de 2020
I am trying to set up what I believe is an ODE to solve for the position, velocity, and acceleration of a buoy given the waves incidence. This is dependent upon the forcing funcition of the buoyance force from the wave on the buoy. I have an array for the buoyant force fb, and I am trying to evaluate my kinematic equation: mz" = ks * a(t) - z' * damp - fb * z. The problem is solving ODE45 as the forcing function changes every iteration so my time step is not constant.
for i = 1:(length(IntSteps)-1)
B = fb(i);
dat = 1.2 * sin(IntSteps(i));
tstart = TimeStep * i;
tend = TimeStep * i + .1;
[t, y] = ode45(@odeBuoy,[tstart tend],[0;0]);
end
My ode function may also be set up incorrectly which is as follows.
  1 comentario
Martelizer
Martelizer el 27 de Oct. de 2020
%% ODE Funciton
function dzdt = odeBuoy(t, y);
global damp B dat ks
dzdt = [y(2), y(2) * damp + B * y(1) + ks * dat];
dzdt = dzdt(:);
end

Iniciar sesión para comentar.

Respuestas (1)

Stephan
Stephan el 27 de Oct. de 2020
Editada: Stephan el 27 de Oct. de 2020
Define your external force vector as an additional input argument for your ode system. Inside the odeBuoy function use the interp1 function to calculate the force that is correct for the timestep chosen by the solver. Also get rid of the for loop.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by