How to use ode 45 to solve a system that is piecewise continous
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!