/
competing_pops.m
180 lines (154 loc) · 5.09 KB
/
competing_pops.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
clear all
close all
k=15; r0=0.5;
b=1; x0=5;
% w=6.3; A = 2.35;
w=6; A=2.5;
r = -10:0.01:10;
planes=1;
Iinp=1;0.8; %osc input amp
transient = 1000; %ms
tf=2000+transient; dt=0.1; N=(tf/dt);
ttstart = 0.1;
ttstop = tf;
fi=1; ff=50; % [Hz]
df=1;
taur=1; taun=25;
Rinf1 = @(x) 1./(1+exp(-(x-x0)));
ainf = @(r) 1./(1+exp(-k*(r-r0)));
anull = @(r,A) -(-w*r - A + x0 + log(r./(1-r)))/b;
if(planes==1)
figure(1);
subplot(1,2,1)
plot(r,ainf(r),'g','LineWidth',2); hold on;
plot(r,anull(r,A),'r','LineWidth',2); hold on;
% plot(r,anull(r,A+Iinp),'r--','LineWidth',2); hold on;
% plot(r,anull(r,A-Iinp),'r--','LineWidth',2); hold on;
xlim([0,1]); ylim([0,1]);
ylabel('second-variable')
title('negative feedback')
set(gca, 'FontName', 'Helvetica','FontSize',20)
subplot(1,2,2)
plot(r,ainf(r),'g','LineWidth',2); hold on;
plot(r,anull(r,A),'r','LineWidth',2); hold on;
% plot(r,anull(r,A+Iinp),'r--','LineWidth',2); hold on;
% plot(r,anull(r,A-Iinp),'r--','LineWidth',2); hold on;
xlim([0,1]); ylim([0,1]);
title('positive feedback')
set(gca, 'FontName', 'Helvetica','FontSize',20)
end
% b=1; w=6; A = 2.5; x0=5;
acum1=[];
acum2=acum1; acum3=acum1; acum4=acum1;
f1 = 50;
for f1 = 50:50
f2 = 20;
% f=0;
pks1=[]; pks2=[];
% for taun = 100:1:100
r1=zeros(1,N); r1(1)=0.4;
n1=zeros(1,N); n1(1)=0.5;
r2=zeros(1,N); r2(1)=0.4;
n2=zeros(1,N); n2(1)=0.5;
Input=zeros(1,N);
for i = 1:N-1
t = i*dt;
if (t<transient)
I1=A;
I2=A;
else
I1 = A+Iinp*sin(2*pi*f1*t*10^-3);
I2 = A+Iinp*sin(2*pi*f2*t*10^-3);
end
%a
r1(i+1) = r1(i) + dt*(-r1(i) + Rinf1(w*r1(i) - b*n1(i) + I1))/taur;
n1(i+1) = n1(i) + dt*(-n1(i) + ainf(r1(i)+r2(i)))/taun;
r2(i+1) = r2(i) + dt*(-r2(i) + Rinf1(w*r2(i) - b*n1(i) + I2))/taur;
% n2(i+1) = n2(i) + dt*(-n2(i) + binf(r2(i)))/taun;
% Input(i) = I;
end
figure(1)
% subplot(2,2,1)
% plot(r1,n1,'-','Color',[0,1,1],'LineWidth',0.1)
% subplot(2,2,2)
% plot(r2,n2,'-','Color',[0,1,1],'LineWidth',0.1)
% subplot(2,2,3)
% plot(r3,n3,'-','Color',[0,1,1],'LineWidth',0.1)
% subplot(2,2,4)
% plot(r4,n4,'-','Color',[0,1,1],'LineWidth',0.1)
figure(1)
subplot(1,2,1)
plot(r1(20000:end),n1(20000:end),'-','Color',[0,1,1],'LineWidth',0.1) %end/2
subplot(1,2,2)
plot(r2(20000:end),n1(20000:end),'-','Color',[0,1,1],'LineWidth',0.1)
figure(4);
subplot(1,2,1)
plot(dt:dt:dt*N,r1,'Color',[0,1,1],'LineWidth',1); hold on;
set(gca,'xtick',[]);
ylabel('r')
set(gca, 'FontName', 'Helvetica','FontSize',20)
subplot(1,2,2)
plot(dt:dt:dt*N,r2,'Color',[0,1,1],'LineWidth',1); hold on;
set(gca,'xtick',[]); set(gca,'ytick',[])
set(gca, 'FontName', 'Helvetica','FontSize',20)
set(gca, 'FontName', 'Helvetica','FontSize',20)
% if(f==1)
% figure(10)
% subplot(1,3,1)
% plot(dt:dt:tf-dt,Input(1:end-1),'Color',[0,1,1],'LineWidth',2);
% title('frequency = 1Hz')
% ylabel('input')
% xlabel('time [ms]')
% set(gca, 'FontName', 'Times New Roman','FontSize',20)
% xlim([0,tf])
% elseif(f==10)
% figure(10)
% subplot(1,3,2)
% plot(dt:dt:tf-dt,Input(1:end-1),'Color',[1,0,1],'LineWidth',2)
% title('frequency = 10Hz')
% xlabel('time [ms]')
% set(gca, 'FontName', 'Times New Roman','FontSize',20)
% xlim([0,tf])
% elseif(f==50)
% figure(10)
% subplot(1,3,3)
% plot(dt:dt:tf-dt,Input(1:end-1),'Color',[0,0,1],'LineWidth',2)
% title('frequency = 50Hz')
% xlabel('time [ms]')
% set(gca, 'FontName', 'Times New Roman','FontSize',20)
% xlim([0,tf])
% end
pks1 = [pks1; length(findpeaks(r1))/2];
pks2 = [pks2; length(findpeaks(r2))/2];
acum1 = [acum1; max(r1(end/2:end)) - min(r1(end/2:end))];% sum(r1)];
acum2 = [acum2; max(r2(end/2:end)) - min(r2(end/2:end))];% sum(r2)];
end
% figure; plot(sum(r1)); hold on; plot(sum(r2))
% figure;
% subplot(2,1,1)
% plot(pks1)
% xlabel('\tau_a [ms]')
% ylabel('Frequency [Hz]')
% title('1')
% set(gca, 'FontName', 'Times New Roman','FontSize',14)
% subplot(2,1,2)
% plot(pks2)
% xlabel('\tau_a [ms]')
% ylabel('Frequency [Hz]')
% title('4')
% set(gca, 'FontName', 'Times New Roman','FontSize',14)
figure(3);
subplot(1,2,1)
plot(acum1,'k','LineWidth',2); hold on;
plot(1,acum1(1),'o','Color',[0,1,1],'MarkerFaceColor',[0,1,1])
plot(10,acum1(10),'o','Color',[1,0,1],'MarkerFaceColor',[1,0,1])
plot(50,acum1(50),'o','Color',[0,0,1],'MarkerFaceColor',[0,0,1])
ylabel('r_{\rm max} - r_{\rm min}')
set(gca, 'FontName', 'Helvetica','FontSize',14)
subplot(1,2,2)
plot(acum2,'k','LineWidth',2); hold on;
plot(1,acum2(1),'o','Color',[0,1,1],'MarkerFaceColor',[0,1,1])
plot(10,acum2(10),'o','Color',[1,0,1],'MarkerFaceColor',[1,0,1])
plot(50,acum2(50),'o','Color',[0,0,1],'MarkerFaceColor',[0,0,1])
set(gca, 'FontName', 'Helvetica','FontSize',14)
%