-
Notifications
You must be signed in to change notification settings - Fork 0
/
dhDataProcess.m
50 lines (44 loc) · 1.43 KB
/
dhDataProcess.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
function f=dhDataProcess(tab)
DV = datevec(tab.OnsetDate); % [N x 6] array
DV = DV(:, 1:3); % [N x 3] array, no time
DV2 = DV;
DV2(:, 2:3) = 0; % [N x 3], day before 01.Jan
%Result = cat(2, DV(:, 1), datenum(DV) - datenum(DV2));
%doy=result(:,2);
doyOnset = cat(1, datenum(DV) - datenum(DV2));
DV = datevec(tab.AdmitDate); % [N x 6] array
DV = DV(:, 1:3); % [N x 3] array, no time
DV2 = DV;
DV2(:, 2:3) = 0; % [N x 3], day before 01.Jan
%Result = cat(2, DV(:, 1), datenum(DV) - datenum(DV2));
%doy=result(:,2);
doyAdmit = cat(1, datenum(DV) - datenum(DV2));
doyOut=doyAdmit+tab.DaysHosp;
days=32:max([doyAdmit;doyOut]);
ldays=length(days);
inc=zeros(ldays,1);
prev=inc;
onset=inc;
doyOut(isnan(doyOut)==1)=days(end)+1;
for i=1:length(doyOnset)
vi=doyAdmit(i)-31:doyOut(i)-32;
inc(doyAdmit(i)-31)=inc(doyAdmit(i)-31)+1;
prev(vi)=prev(vi)+1;
onset(doyOnset(i)-31)=onset(doyOnset(i)-31)+1;
end
f=prev;
figure
cmap=lines(7);
fs=10; lw=2;
hold on
plot(days,cumsum(onset),'-','linewidth',lw,'color',cmap(2,:))
plot(days,cumsum(inc),'-','linewidth',lw,'color',cmap(1,:))
plot(days,inc,'--','linewidth',lw,'color',cmap(1,:))
plot(days,prev,'k-','linewidth',lw)
xlabel('Day (since 1st Feb)')
ylabel('Hospitalisations')
set(gca,'fontsize',fs)
legend('Total symptomatic','Total hospitalised','New hospitalisations','Number currently hospitalised','location','NW')
grid on
grid minor
box on