A question about FitzHugh-Nagumo model

14 ビュー (過去 30 日間)
shuhao hu
shuhao hu 2021 年 11 月 9 日
コメント済み: shuhao hu 2021 年 11 月 15 日
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

採用された回答

Alan Stevens
Alan Stevens 2021 年 11 月 9 日
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 件のコメント
Alan Stevens
Alan Stevens 2021 年 11 月 12 日
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.
shuhao hu
shuhao hu 2021 年 11 月 15 日
Thank you very much!I got it,you must be Jesus!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by