How to use ode 45 to solve a system that is piecewise continous

조회 수: 1 (최근 30일)
Sudharsana Iyengar
Sudharsana Iyengar 2013년 10월 10일
I am trying to use ode45 to solve a differential equation in which a parameter depends on time. When t is even the parameter is zero and 'a' for odd case. I wrote two functions F1 and F2, that represented my system with and without the parameter a. I tried to use the if statement inside a for loop to execute ode
x=[0 1]'
for t=0:0.01:100
z=t/2;
if z-floor(z) = 0
ode = @(t,x)F1(t,x);
[t,x]=ode45(ode,t,x);
else
ode = @(t,x)F2(t,x);
[t,x]=ode45(ode,t,x);
end
end
(plot(x(:,1),x(:,2)))
how do i make sure that output of at t=1 is taken as input at t=2 as the system parameter alternate

답변 (0개)

카테고리

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