A question about FitzHugh-Nagumo model
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shuhao hu
am 9 Nov. 2021
Kommentiert: shuhao hu
am 15 Nov. 2021
I`ve been trying to built the FitzHugh-Nagumo model with a changeable input,but I failed to make the input changeable and I was unable to figure out why.
I defined three variables which I thought they should be the same,but only the variable 'eq1' and the way I put in the comment worked out,the others ended without graph out.I wonder how could this happened and how should I change the code of 'eq2' and 'eq3' .
syms t
tspan = [0 100];
v0 = 0; w0 = 0;
IC = [v0 w0];
A=0.5;
B=0.05;
Epsilon=0.005;
I=sin(t);
eq1=@(t,vw)fn(t,vw,A,B,Epsilon,sin(t));
eq2=@(t,vw)fn(t,vw,A,B,Epsilon,0)+[sin(t);0];
eq3=@(t,vw)fn(t,vw,A,B,Epsilon,I);
[t, vw] = ode45(eq1, tspan,IC);
%[t, vw] = ode45(@(t,vw)fn(t,vw,A,B,Epsilon,sin(t)), tspan,IC);
v = vw(:,1);
w = vw(:,2);
% results
plot(t,v,'r',t,w,'b'),grid
xlabel('t'),ylabel('v and w')
legend('v','w')
function dvwdt = fn(~,vw,A,B,Epsilon,I)
a = A;
b = B;
epsilon = Epsilon;
i = I;
v = vw(1);
w = vw(2);
dvwdt = [(v*(v-a)*(1-v)-w+i)/epsilon;
v-w-b];
end
0 Kommentare
Akzeptierte Antwort
Alan Stevens
am 9 Nov. 2021
Like this?
tspan = [0 100];
v0 = 0; w0 = 0;
IC = [v0 w0];
A=0.5;
B=0.05;
Epsilon=0.005;
I=@(t)sin(t); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eq1=@(t,vw)fn(t,vw,A,B,Epsilon,sin(t));
eq2=@(t,vw)fn(t,vw,A,B,Epsilon,0)+[sin(t);0];
eq3=@(t,vw)fn(t,vw,A,B,Epsilon,I(t));
[t1, vw1] = ode45(eq1, tspan,IC);
[t2, vw2] = ode45(eq2, tspan,IC);
[t3, vw3] = ode45(eq3, tspan,IC);
v1 = vw1(:,1); v2 = vw2(:,1); v3 = vw3(:,1);
w1 = vw1(:,2); w2 = vw2(:,2); w3 = vw3(:,2);
% results
figure
plot(t1,v1,'r',t1,w1,'b'),grid
xlabel('t1'),ylabel('v1 and w1')
legend('v1','w1')
figure
plot(t2,v2,'r',t2,w2,'b'),grid
xlabel('t2'),ylabel('v2 and w2')
legend('v2','w2')
figure
plot(t3,v3,'r',t3,w3,'b'),grid
xlabel('t3'),ylabel('v3 and w3')
legend('v3','w3')
function dvwdt = fn(~,vw,A,B,Epsilon,I)
a = A;
b = B;
epsilon = Epsilon;
i = I;
v = vw(1);
w = vw(2);
dvwdt = [(v*(v-a)*(1-v)-w+i)/epsilon;
v-w-b];
end
3 Kommentare
Alan Stevens
am 12 Nov. 2021
In eq2, the value of I passed to fn is zero. To see the effect this has change eq2 so that it doesn't add the [sin(t); 0] term. You will then see that this last vector just produces oscillations about two very different values.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!