ODE solver: how to integrate a system with a vector of parameters?

2 vues (au cours des 30 derniers jours)
Uladzislau
Uladzislau le 24 Jan 2020
Commenté : Uladzislau le 24 Jan 2020
Hello! I would like to ask how can I solve the system below for V varying from 1 to 1.2 with step 0.001? My aim is to plot bifurcation diagramm.
function [out] = chuaSmoothIris(~,in,alpha, beta, A, C, V)
x = in(1);
y = in(2);
z = in(3);
xdot = alpha*y - A*alpha*x^3 - C*alpha*x - V*alpha*x;
ydot = x - y + z;
zdot = -beta*y;
out = [xdot ydot zdot]';
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
t = [0 400];
y = [0.004 0 0];
alpha = 15.6;
beta = 28;
A = 0.002;
C = -1.3;
V = 1:0.001:1.2;
[t,y] = ode45(@(t, y) chuaSmoothIris(t, y, alpha', beta', A', C', V'), t, y );

Réponse acceptée

J. Alex Lee
J. Alex Lee le 24 Jan 2020
Are you just looking for solving the ODE as many times as you have different values of V?
t = [0 400];
y = [0.004 0 0];
alpha = 15.6;
beta = 28;
A = 0.002;
C = -1.3;
V = 1:0.001:1.2;
for i = 1:length(V)
[t,y] = ode45(@(t, y) chuaSmoothIris(t, y, alpha', beta', A', C', V(i)), t, y );
end
  3 commentaires
J. Alex Lee
J. Alex Lee le 24 Jan 2020
Oops. It's because you are overwriting the variable y.
t = [0 400];
y0 = [0.004 0 0]; % give this a special name
alpha = 15.6;
beta = 28;
A = 0.002;
C = -1.3;
V = 1:0.001:1.2;
for i = 1:length(V)
[t,y] = ode45(@(t, y) chuaSmoothIris(t, y, alpha', beta', A', C', V(i)), t, y0 );
end
Uladzislau
Uladzislau le 24 Jan 2020
It works!!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by