-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_comparison_results_for_alpha.m
More file actions
82 lines (74 loc) · 3 KB
/
plot_comparison_results_for_alpha.m
File metadata and controls
82 lines (74 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
function plot_comparison_results_for_alpha(results_lin, results_nonlin, params, alphas, disturbanceShow)
% Use fixed colors for each alpha
colors = {'b', 'r', 'g'}; % For alpha = 0.1, 0.5, 0.9
%% --------- LINEAR SYSTEM PLOTS ---------
figure;
% Output
subplot(2,1,1); hold on;
plot(results_lin{1}.time, params.Ref, 'k-', 'LineWidth', 1.5); % Same Ref for all
for i = 1:length(alphas)
plot(results_lin{i}.time, results_lin{i}.Ref_filtered, [colors{i} '--'], 'LineWidth', 1.2);
plot(results_lin{i}.time, results_lin{i}.Y, 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');
legend({'Ref', ...
'\alpha = 0.1 filtered', '\alpha = 0.1 Y', ...
'\alpha = 0.5 filtered', '\alpha = 0.5 Y', ...
'\alpha = 0.9 filtered', '\alpha = 0.9 Y'}, ...
'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
ylim([-2.1, 0.2]);
% Input
subplot(2,1,2); hold on;
for i = 1:length(alphas)
plot(results_lin{i}.time, results_lin{i}.U, 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');
legend({'\alpha = 0.1', '\alpha = 0.5', '\alpha = 0.9'}, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
%% --------- NONLINEAR SYSTEM PLOTS ---------
figure;
% Output
subplot(2,1,1); hold on;
plot(results_nonlin{1}.time, params.Ref, 'k-', 'LineWidth', 1.5);
for i = 1:length(alphas)
plot(results_nonlin{i}.time, results_nonlin{i}.Ref_filtered, [colors{i} '--'], 'LineWidth', 1.2);
plot(results_nonlin{i}.time, results_nonlin{i}.Y, 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');
legend({'Ref', ...
'\alpha = 0.1 filtered', '\alpha = 0.1 Y', ...
'\alpha = 0.5 filtered', '\alpha = 0.5 Y', ...
'\alpha = 0.9 filtered', '\alpha = 0.9 Y'}, ...
'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
ylim([-2.1, 0.2]);
% Input
subplot(2,1,2); hold on;
for i = 1:length(alphas)
plot(results_nonlin{i}.time, results_nonlin{i}.U, colors{i}, 'LineWidth', 1.5);
end
if disturbanceShow
xline(params.disturbance_start_time, 'k--', 'Dist Start', 'LabelVerticalAlignment', 'bottom');
end
title('Control Input (Nonlinear)');
xlabel('Time (s)'); ylabel('Input');
legend({'\alpha = 0.1', '\alpha = 0.5', '\alpha = 0.9'}, 'Location', 'best');
grid on;
xlim([0, params.N * params.Ts]);
end