-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_comparison_results.m
More file actions
109 lines (84 loc) · 3 KB
/
plot_comparison_results.m
File metadata and controls
109 lines (84 loc) · 3 KB
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
function plot_comparison_results(results_lin, results_nonlin, params, values, name, disturbanceShow)
% Linear Outputs and inputs
figure;
subplot(2, 1, 1);
hold on;
plot(results_lin{1}.time, params.Ref, 'k-', ...
results_lin{1}.time, results_lin{1}.Ref_filtered, 'k--.', 'LineWidth', 1.5);
for i = 1:length(values)
plot(results_lin{i}.time, results_lin{i}.Y, params.colors{i}, 'LineWidth', 1.5);
end
if disturbanceShow
xline(params.disturbance_start_time, 'k--', 'Dist Start', 'LabelVerticalAlignment', 'bottom');
end
title('Output (Linear)');
xlabel('Time (s)'); ylabel('Output');
% Legends
legend_entries = {'Ref', 'Filtered Ref'};
for i = 1:length(values)
legend_entries{end + 1} = sprintf('%s = %g', name, values(i));
end
legend(legend_entries, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
ylim([-2.1, 0.2]);
subplot(2, 1, 2);
hold on;
for i = 1:length(values)
plot(results_lin{i}.time, results_lin{i}.U, params.colors{i}, 'LineWidth', 1.5);
end
if disturbanceShow
xline(params.disturbance_start_time, 'k--', 'Dist Start', 'LabelVerticalAlignment', 'bottom');
end
title('Control Input (Linear)');
xlabel('Time (s)'); ylabel('Input');
% Legends
legend_entries = {};
for i = 1:length(values)
legend_entries{end + 1} = sprintf('%s = %g', name, values(i));
end
legend(legend_entries, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
% Noninear Outputs and inputs
figure;
subplot(2, 1, 1);
hold on;
plot(results_nonlin{1}.time, params.Ref, 'k-', ...
results_nonlin{1}.time, results_nonlin{1}.Ref_filtered, 'k--.', 'LineWidth', 1.5);
for i = 1:length(values)
plot(results_nonlin{i}.time, results_nonlin{i}.Y, params.colors{i}, 'LineWidth', 1.5);
end
if disturbanceShow
xline(params.disturbance_start_time, 'k--', 'Dist Start', 'LabelVerticalAlignment', 'bottom');
end
title('Output (Nonlinear)');
xlabel('Time (s)'); ylabel('Output');
% Legends
legend_entries = {'Ref', 'Filtered Ref'};
for i = 1:length(values)
legend_entries{end + 1} = sprintf('%s = %g', name, values(i));
end
legend(legend_entries, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
ylim([-2.1, 0.2]);
subplot(2, 1, 2);
hold on;
for i = 1:length(values)
plot(results_nonlin{i}.time, results_nonlin{i}.U, params.colors{i}, 'LineWidth', 1.5);
end
if disturbanceShow
xline(params.disturbance_start_time, 'k--', 'Dist Start', 'LabelVerticalAlignment', 'bottom');
end
title('Control Input (Noninear)');
xlabel('Time (s)'); ylabel('Input');
% Legends
legend_entries = {};
for i = 1:length(values)
legend_entries{end + 1} = sprintf('%s = %g', name, values(i));
end
legend(legend_entries, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
end