-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotmz.m
78 lines (64 loc) · 1.53 KB
/
plotmz.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
% function fh = plotmz(t,mzSP,mztrue,fh,options)
function fh = plotmz(varargin)
%% Check and assign inputs
if nargin >= 2
mzSP = varargin{1};
mztrue = varargin{2};
else
error('Not enough inputs.')
end
% Figure handel
if nargin >= 3
if ~isempty(varargin{3})
fh = figure(varargin{3});
else
fh = figure;
end
else
fh = figure;
end
% Options
options.data.col = 'b';
options.data.area_col = [0.7,0.7,1];
options.data.ls = '-';
options.data.mean_lw = 2;
options.data.bound_lw = 1;
options.sim.col = 'r';
options.sim.ls = '--';
options.sim.mean_lw = 2;
options.sim.bound_lw = 1;
options.error.col = 'b';
options.error.ls = '-';
options.error.lw = 1;
if nargin == 4
options = setdefault(varargin{4},options);
end
%% Subplot dimensions
n_y = 1;
n_t = size(mztrue,1);
nr = 1;
nc = 2;
%% Visualization: Data and Simulation
% Data and simulation
subplot(nr,nc,1); hold off;
lh(1) = plot(1:n_t,mzSP(:,1),'-',...
'linewidth',options.data.mean_lw,...
'linestyle',options.data.ls,...
'color',options.data.col); hold on;
lh(2) = plot(1:n_t,mztrue(:,1),'-',...
'linewidth',options.sim.mean_lw,...
'linestyle',options.sim.ls,...
'color',options.sim.col); hold on;
xlabel('time'); ylabel('state');
xlim([1,n_t]);
legend(lh,{'mz SP','mz sampled'});
subplot(nr,nc,2); hold off;
plot(1:n_t,mzSP(:,1)-mztrue(:,1),'-',...
'linewidth',options.error.lw,...
'linestyle',options.error.ls,...
'color',options.error.col); hold on;
xlabel('time'); ylabel('error');
xlim([1,n_t]);
%%
drawnow
end