-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotMA2sub.m
175 lines (173 loc) · 4.17 KB
/
plotMA2sub.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
%function f=plotMAs2sub(Asus,Arec,NN,NNbar,tmin,tmax)
function f=plotMA2sub(Asus,Arec,NN,NNbar,tmin,tmax,fp)
Asus=Asus(:,tmin:tmax);
Arec=Arec(:,tmin:tmax);
%ar=1;
tauend=size(Arec,2);
nbar=length(NNbar); n=length(NN);
R1=Arec(1:nbar,:);
R2=Arec(nbar+1:end,:);
%repNNbar=repmat(NNbar,1,tauend);
repNN=repmat(NN,1,tauend);
%R1=R1.*repNNbar; R2=R2.*repNNbar;
R1=R1(1:n,:)+R1(n+1:2*n,:)+R1(2*n+1:3*n,:)+R1(3*n+1:end,:);
R2=R2(1:n,:)+R2(n+1:2*n,:)+R2(2*n+1:3*n,:)+R2(3*n+1:end,:);
attack=R1+R2; attack=sum(attack,1)/sum(NN);
R1=R1./repNN; R1(repNN==0)=0;
R2=R2./repNN; R2(repNN==0)=0;
f=R1+R2;
maxAttack=max(max(f));
%%
%Comment out if don't want ccpand:
%{
thresh=0.005;
yy=1:tauend;
X=zeros(1,tauend); Y=X; Z=X;
fx=R1;
fsum=max(fx,[],1);
fx(:,fsum<thresh)=[];
yyi1=yy; yyi1(fsum<thresh)=[];
lf=size(fx,2);
for k=1:lf
cck=corrcoef(fx(:,k),fp);
X(yyi1(k))=cck(2);
end
%
gx=R2;
gsum=max(gx,[],1);
gx(:,gsum<thresh)=[];
yyi1=yy; yyi1(gsum<thresh)=[];
lg=size(gx,2);
for k=1:lg
cck=corrcoef(gx(:,k),fp);
Y(yyi1(k))=cck(2);
end
%
hx=f;
hsum=max(hx,[],1);
hx(:,hsum<thresh)=[];
yyi1=yy; yyi1(hsum<thresh)=[];
lh=size(hx,2);
for k=1:lh
cck=corrcoef(hx(:,k),fp);
Z(yyi1(k))=cck(2);
end
ymin=min([X,Y,Z,0]);
%}
%%
fs=12; lw=1;%30;%Font size
%
figure
%{
T=1:tauend;
plot(T,[R1;R2],'-','linewidth',lw)%,'color',[.5,0,0])%'o-'
xlabel('Time (years)','FontSize',fs)
ylabel('R (N1N1)','FontSize',fs)
%axis ([0,tauend,0,1]);
set(gca,'FontSize',fs);
grid on
grid minor
%}
%
cmod=.3;
T=tmin:tmax;%1:tauend;
subplot(2,1,1)
hold on
plot(T,R1','-','linewidth',lw)%,'color',[.5,0,0])%'o-'
hold off
%xlabel('Time (years)','FontSize',fs)
ylabel('R (H1N1)','FontSize',fs)
axis ([tmin-1,tmax,0,maxAttack]);
%axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
subplot(2,1,2)
hold on
plot(T,R2','-','linewidth',lw)%,'color',[0,0,.5])%'o-'
hold off
xlabel('Time (years)','FontSize',fs)
ylabel('R (H3N2)','FontSize',fs)
axis ([tmin-1,tmax,0,maxAttack]);
%axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
%Comment out if don't want ccpand (or total):
%{
figure
subplot(2,1,1)
hold on
s=plot(T,f','-','linewidth',lw);%,'color',[0,0,.5])%'o-'
plot(T,attack,'-','color',cmod*[1,1,1],'linewidth',2)
hold off
%alpha(s,.5)
%xlabel('Time (years)','FontSize',fs)
ylabel('R (total)','FontSize',fs)
axis ([tmin-1,tmax,0,maxAttack]);
%axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
subplot(2,1,2)
hold on
plot([0,tauend],[0,0],'k-','linewidth',1)
h1=plot(T,X,'-','linewidth',2);
h2=plot(T,Y,'-','linewidth',2);
h3=plot(T,Z,'-','color',cmod*[1,1,1],'linewidth',2);
hold off
%alpha(s,.5)
xlabel('Time (years)','FontSize',fs)
ylabel('cc_{pand}','FontSize',fs)
axis ([tmin-1,tmax,-1,1]);
%axis tight
set(gca,'FontSize',fs);
legend([h1,h2,h3],'H1','H3','Total','location','SW')
grid on
grid minor
box on
%}
%{
T=tmin:tmax;%1:tauend;
subplot(3,1,1)
hold on
plot(T,R1','-','linewidth',lw)%,'color',[.5,0,0])%'o-'
hold off
xlabel('Time (years)','FontSize',fs)
ylabel('R (H1N1)','FontSize',fs)
axis ([tmin-1,tmax,0,maxAttack]);
%axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
subplot(3,1,2)
hold on
plot(T,R2','-','linewidth',lw)%,'color',[0,0,.5])%'o-'
hold off
xlabel('Time (years)','FontSize',fs)
ylabel('R (H3N2)','FontSize',fs)
axis ([tmin-1,tmax,0,maxAttack]);
%axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
subplot(3,1,3)
hold on
s=plot(T,f','-','linewidth',lw);%,'color',[0,0,.5])%'o-'
plot(T,attack,'-','color',.2*[1,1,1],'linewidth',2)
hold off
%alpha(s,.5)
xlabel('Time (years)','FontSize',fs)
ylabel('R (total)','FontSize',fs)
axis ([tmin-1,tmax,y0,maxAttack]);
axis tight
set(gca,'FontSize',fs);
grid on
grid minor
box on
%}