-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZMW_sim_Gelsolin_4Steps.m
More file actions
141 lines (110 loc) · 3.49 KB
/
ZMW_sim_Gelsolin_4Steps.m
File metadata and controls
141 lines (110 loc) · 3.49 KB
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
function [simZMW] = ZMW_sim_Gelsolin_4Steps(Ac,cycles)
% Ac = 0.8;
rates_onR = [0.1 0.3 0.6];
rates_on = rates_onR.*Ac;
rates_off = [0 0.2 3];
% cycles = 9;
SNR =0;
h = waitbar(0,'Please wait, simulating traces...');
for i = 1:cycles
clear MonTre t tM k tMon Mon
waitbar(i / cycles)
% clear all
Ttot = 800;
dt = 0.2;
ttot = Ttot/dt;
Mon = zeros(ttot,1);
MonTre = zeros(ttot,1);
tM = zeros(ttot,1);
k = 1;
t = [dt:dt:Ttot];
tM0 = random(makedist('exp',1/rates_on(1)));
tMon(1) = round(tM0./dt);
Mon(tMon(1)+1) = 1;
tM(1) = tM0;
while sum(tMon) < ttot
% sum(tM);
% tic
k = k+1;
MonTre = cumsum(Mon);
tM3 = random(makedist('exp',1/rates_on(3)));
tM4 = random(makedist('exp',1/rates_off(3)));
kon3 = round(tM3./dt);
koff3 = round(tM4./dt);
if MonTre(end) == 1
tM1 = random(makedist('exp',1/rates_on(2)));
kon2 = round(tM1./dt);
tMon(k) = kon2;
tM(k) = tM1;
Mon(sum(tMon(1:k))+1) = 1;
elseif MonTre(end) == 2
tM2 = random(makedist('exp',1/rates_off(2)));
koff2 = round(tM2./dt);
tM3 = random(makedist('exp',1/rates_on(3)));
kon3 = round(tM3./dt);
if kon3 < koff2
tMon(k) = kon3;
tM(k) = tM3;
Mon(sum(tMon(1:k))+1) = 1;
else
tMon(k) = koff2;
tM(k) = tM2;
Mon(sum(tMon(1:k))+1) = -1;
end
else
tM3 = random(makedist('exp',1/rates_on(3)));
tM4 = random(makedist('exp',1/rates_off(3)));
kon3 = round(tM3./dt);
koff3 = round(tM4./dt);
if kon3 < koff3
tMon(k) = kon3;
tM(k) = tM3;
Mon(sum(tMon(1:k))+1) = 1;
else
tMon(k) = koff3;
tM(k) = tM4;
Mon(sum(tMon(1:k))+1) = -1;
end
end
% koff3 < kon3 & MonTre(end) > 2 & MonTre(end) > 0
% tMon(k) = koff3;
% tM(k) = tM4;
% Mon(sum(tMon(1:k))+1) = -1;
%
% kon2 < koff2 & MonTre(end) == 1
% tMon(k) = kon2;
% tM(k) = tM1;
% Mon(sum(tMon(1:k))+1) = 1;
end
% toc
simZMW.time{i} = t;
simZMW.monomers{i} = MonTre;
simZMW.Tmon{i} = tMon;
simZMW.TM{i} = tM;
simZMW.noise{i} = MonTre + (1/SNR)*randn(numel(MonTre),1);
% toc
end
simZMW.cycles = cycles;
close(h)
if cycles == 1
tdum1 = cell2mat(simZMW.noise);
tdum2 = cell2mat(simZMW.monomers);
figure
plot(t,tdum1,'Color',[0.8 0.8 0.8])
hold on
plot(t,tdum2,'k')
xlabel( ' Time (s)' );
ylabel( 'Intensity (a.u.)' );
elseif cycles == 9
figure
tdum1 = cell2mat(simZMW.noise);
tdum2 = cell2mat(simZMW.monomers);
for j = 1:cycles
subplot(3,3,j)
plot(t,tdum1(:,j),'Color',[0.8 0.8 0.8])
hold on
plot(t,tdum2(:,j),'k')
xlabel( ' Time (s)' );
ylabel( 'Intensity (a.u.)' );
end
end