How to use ode 45 to solve a system that is piecewise continous
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!