Looping over a parameter of a function used in ode45
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am modeling the Fitzhugh-Nagumo model using ode45, and I ultimately want to try creating a bifurcation diagram by solving the ode over a range of external currents (i) and plotting the maximum voltage response with respect to the applied current. My code is attached. I recognize that it is clearly incorrect, but I'm not sure how to solve this. Might I have to have 'i' (current) be another input argument for 'dvwdt'? I am a little new to working with ode45 to solve dynamic systems, so any help would be greatly appreciated!
for j = 1:25
i = j/10;
tspan = [0 1000]; % start and end times
v0 = 0; w0 = 0; % initial values
IC = [v0 w0];
% Call ode45
[t, vw] = ode45(@fn, tspan,IC);
% Extract individual solution values
v = vw(:,1);
w = vw(:,2);
% Plot results
maxv = max(v);
plot(i,maxv)
end
function dvwdt = fn(~,vw)
a = 0.8;
b = 0.7;
g = 0.08;
i = 0;
v = vw(1);
w = vw(2);
dvwdt = [v-v^3/3 - w + i;
g*(v+a-b*w)];
end
0 Commenti
Risposte (1)
Steven Lord
il 15 Dic 2020
So you want to pass i (BTW I would use different variable names than i and j, as they already have meanings in MATLAB: see doc i and doc j for more information) into your ODE function rather than computing it inside? See the "Pass Extra Parameters to ODE Function" example on the documentation page for the ode45 function.
0 Commenti
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!