Problem Solving Kinematic ODE with Forcing Function

조회 수: 1 (최근 30일)
Martelizer
Martelizer 2020년 10월 27일
댓글: Martelizer 2020년 10월 27일
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
Martelizer
Martelizer 2020년 10월 27일
%% 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

댓글을 달려면 로그인하십시오.

답변 (1개)

Stephan
Stephan 2020년 10월 27일
편집: Stephan 2020년 10월 27일
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.

카테고리

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