-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotSCTLstat.m
212 lines (195 loc) · 6.53 KB
/
plotSCTLstat.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
% function plotSCTLstatstat(Data,Sim,fh,options)
function plotSCTLstat(varargin)
persistent fh
%% Check and assign inputs
if nargin >= 2
Data = varargin{1};
Sim = varargin{2};
else
error('Not enough inputs.')
end
% Figure handle
s = varargin{3};
if(isempty(fh))
fh(s) = figure;
else
if length(fh) < s
fh(s) = figure;
elseif(isempty(fh(s)))
fh(s) = figure;
end
end
figure(fh(s));
% Options
options.data.col = 'b';
options.data.ls = '-';
options.data.lw = 2;
options.sim.col = 'r';
options.sim.ls = '-';
options.sim.lw = 2;
options.error.col = 'b';
options.error.ls = '-';
options.error.lw = 1;
options.title = '';
if nargin == 4
options = setdefault(varargin{4},options);
end
set(gcf,'Name',options.title);
% %% Subplot dimensions
% n_y = size(Data.SCTLstat.Y,2);
% if ~isempty(Sim)
% nc = 2;
% nr = n_y;
% else
% nc = ceil(sqrt(n_y));
% nr = ceil(n_y/nc);
% end
% %% Visualization: Data and Simulation
% if ~isempty(Sim)
% % Data
% % Means
% subplot(2,2,1); hold off;
% plot(1:length(Data.SCTLstat.mz),Data.SCTLstat.mz,'-o',...
% 'linewidth',options.data.lw,...
% 'linestyle',options.data.ls,...
% 'color',options.data.col); hold on;
% plot(1:length(Data.SCTLstat.mz),Sim.mz,'-x',...
% 'linewidth',options.sim.lw,...
% 'linestyle',options.sim.ls,...
% 'color',options.sim.col); hold on;
% xlabel('(t,y(t))'); ylabel('mean');
% xlim([0.5,length(Data.SCTLstat.mz)+0.5]);
%
% % Covariances
% subplot(2,2,3); hold off;
% plot(1:length(Data.SCTLstat.Cz(:)),Data.SCTLstat.Cz(:),'-o',...
% 'linewidth',options.data.lw,...
% 'linestyle',options.data.ls,...
% 'color',options.data.col); hold on;
% plot(1:length(Data.SCTLstat.Cz(:)),Sim.Cz(:),'-x',...
% 'linewidth',options.sim.lw,...
% 'linestyle',options.sim.ls,...
% 'color',options.sim.col); hold on;
% xlabel('pairs of (t,y(t))'); ylabel('covariance');
% xlim([0.5,length(Data.SCTLstat.Cz(:))+0.5]);
%
% % Error
% % Means
% subplot(2,2,2); hold off;
% plot(1:length(Data.SCTLstat.mz),Data.SCTLstat.mz-Sim.mz,'-o',...
% 'linewidth',options.error.lw,...
% 'linestyle',options.error.ls,...
% 'color',options.error.col); hold on;
% xlabel('(t,y(t))'); ylabel('error of mean');
% xlim([0.5,length(Data.SCTLstat.mz)+0.5]);
%
% % Covariances
% subplot(2,2,4); hold off;
% plot(1:length(Data.SCTLstat.Cz(:)),Data.SCTLstat.Cz(:)-Sim.Cz(:),'-o',...
% 'linewidth',options.error.lw,...
% 'linestyle',options.error.ls,...
% 'color',options.error.col); hold on;
% xlabel('pairs of (t,y(t))'); ylabel('error of covariance');
% xlim([0.5,length(Data.SCTLstat.Cz(:))+0.5]);
% end
%
% %% Visualization: Data
% if isempty(Sim)
% % Means
% subplot(2,1,1); hold off;
% plot(1:length(Data.SCTLstat.mz),Data.SCTLstat.mz,'-o',...
% 'linewidth',options.data.lw,...
% 'linestyle',options.data.ls,...
% 'color',options.data.col); hold on;
% xlabel('(t,y(t))'); ylabel('mean');
% xlim([0.5,length(Data.SCTLstat.mz)+0.5]);
%
% % Covariances
% subplot(2,1,2); hold off;
% plot(1:length(Data.SCTLstat.Cz(:)),Data.SCTLstat.Cz(:),'-o',...
% 'linewidth',options.data.lw,...
% 'linestyle',options.data.ls,...
% 'color',options.data.col); hold on;
% xlabel('pairs of (t,y(t))'); ylabel('covariance');
% xlim([0.5,length(Data.SCTLstat.Cz(:))+0.5]);
% end
%% Visualization: Data and Simulation
if ~isempty(Sim)
% Number of outputs
ny = size(Data.SCTLstat.mz,2);
% Means
for i = 1:ny
subplot(ny+1,2*ny,[2*i-1,2*i]); hold off;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i),'-',...
'linewidth',options.data.lw,...
'linestyle',options.data.ls,...
'color',options.data.col); hold on;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i)-3*Data.SCTLstat.Sigma_mz(:,i),'-',...
'linewidth',options.error.lw,...
'linestyle',options.error.ls,...
'color',options.error.col); hold on;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i)+3*Data.SCTLstat.Sigma_mz(:,i),'-',...
'linewidth',options.error.lw,...
'linestyle',options.error.ls,...
'color',options.error.col); hold on;
plot(Data.SCTLstat.time,Sim.mz(:,i),'-',...
'linewidth',options.sim.lw,...
'linestyle',options.sim.ls,...
'color',options.sim.col); hold on;
xlabel('time'); ylabel('mean');
xlim([Data.SCTLstat.time(1),Data.SCTLstat.time(end)]);
end
% Covariances - Data
I = [];
for i = 1:ny
I = [I,(2*i*ny+1):((2*i+1)*ny)];
end
Cz_abs_max = max([max(abs(Data.SCTLstat.Cz(:))),max(abs(Sim.Cz(:)))]);
subplot(ny+1,2*ny,I); hold off;
imagesc(Data.SCTLstat.Cz,Cz_abs_max*[-1,1]); hold on;
xlabel('column'); ylabel('row');
colorbar;
caxis([min(min(min(Data.SCTLstat.Cz,Cz_abs_max))),max(max(max(Data.SCTLstat.Cz,Cz_abs_max)))])
% Covariances - Simulation
I = [];
for i = 1:ny
I = [I,((2*i+1)*ny+1):((2*i+2)*ny)];
end
subplot(ny+1,2*ny,I); hold off;
imagesc(Sim.Cz,Cz_abs_max*[-1,1]); hold on;
xlabel('column'); ylabel('row');
colorbar;
caxis([min(min(min(Data.SCTLstat.Cz,Cz_abs_max))),max(max(max(Data.SCTLstat.Cz,Cz_abs_max)))])
end
%% Visualization: Data
if isempty(Sim)
% Number of outputs
ny = size(Data.SCTLstat.mz,2);
% Means
for i = 1:ny
subplot(ny+1,ny,i); hold off;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i),'-',...
'linewidth',options.data.lw,...
'linestyle',options.data.ls,...
'color',options.data.col); hold on;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i)-3*Data.SCTLstat.Sigma_mz(:,i),'-',...
'linewidth',options.error.lw,...
'linestyle',options.error.ls,...
'color',options.error.col); hold on;
plot(Data.SCTLstat.time,Data.SCTLstat.mz(:,i)+3*Data.SCTLstat.Sigma_mz(:,i),'-',...
'linewidth',options.error.lw,...
'linestyle',options.error.ls,...
'color',options.error.col); hold on;
xlabel('time'); ylabel('mean');
xlim([Data.SCTLstat.time(1),Data.SCTLstat.time(end)]);
end
% Covariances
Cz_abs_max = max(abs(Data.SCTLstat.Cz(:)));
subplot(ny+1,ny,(ny+1):(ny+1)*ny); hold off;
imagesc(Data.SCTLstat.Cz,Cz_abs_max*[-1,1]); hold on;
xlabel('column'); ylabel('row');
colorbar;
end
%%
drawnow
end