-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrmpc_plot_r13b.m
110 lines (93 loc) · 1.91 KB
/
rmpc_plot_r13b.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
% RMPC_PLOT_R13b
%
% function data_xu = rmpc_plot_r13b(varargin)
function data_xu = rmpc_plot_r13b(plot_data)
% Open new figure
%
fh = fig_opened;
if(isempty(fh))
fh = 1;
else
fh = fh(end) + 1;
end
style{1,1} = '-';
style{2,1} = '-';
style{3,1} = '-';
style{4,1} = '-';
col{1,1} = [0 0 1];
col{2,1} = [1 0 0];
col{3,1} = [0 0.7 0];
col{4,1} = [0.6 0 0.4];
col{5,1} = [1 0.6 0];
col{6,1} = 'm';
for n = 1 : nargin
style_n = n;
if(style_n > length(style))
style_n = 1;
end % if
col_n = n;
if(col_n > length(col))
col_n = 1;
end % if
data = plot_data{n};
data_xu{1,1} = data.x;
data_xu{2,1} = data.u;
if(exist('data.ts') ~= 1)
data.ts = 1; % Default value of sampling time "ts"
end %
ts = data.ts;
% Problem Sizes
%
nx = size(data.x{1},1);
nu = size(data.u{1},1);
nv = size(data.x,1);
ylab_str{1} = 'x';
ylab_str{2} = 'u';
% Init Figure
%
figure(fh)
nb = [nx,nu]; % number of variabl-types (states&inputs)
for b = 1 : length(nb)
subplot(2,1,b)
hold on
xlabel('t')
ylabel(ylab_str{b})
box on
end % for b
for b = 1 : length(nb)
str_leg = {};
cnt_leg = 0; % counter of legend items
d = data_xu{b};
t = [0:size(d{1},2)-1]'*ts;
for v = 1 : nv
for k = 1 : nb(b)
subplot(2,1,b)
if(b == 1)
plot(t,d{v}(k,:),style{style_n},'Color',col{col_n})
else
stairs(t,d{v}(k,:),style{style_n},'Color',col{col_n})
end
% plot(t,d{v}(:,k),style{style_n},'Color',col{col_n})
cnt_leg = cnt_leg + 1;
end % for k
end % for v
end % b
plottools(fh,'on')
% plottools(fh,'off')
end % for n
for b = 1 : length(nb)
subplot(2,1,b)
leg = [];
for n = 1 : nargin
data = plot_data{n};
data_xu{1,1} = data.x;
data_xu{2,1} = data.u;
leg_item = dataleg(data_xu{b});
leg = [leg;leg_item];
legend(leg)
legend('off')
% legend('location','best')
% legend('location','bestoutside')
end % for n
end % for b
end % function