Work on first section + figures
This commit is contained in:
605
matlab/index.org
605
matlab/index.org
@@ -185,9 +185,10 @@ set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Magnitude');
|
||||
hold off;
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
ylim([5e-4, 20]);
|
||||
ylim([1e-4, 20]);
|
||||
xticks([0.1, 1, 10, 100, 1000]);
|
||||
legend('location', 'northeast', 'FontSize', 8);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
@@ -278,7 +279,8 @@ ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
ylim([1e-4, 20]);
|
||||
yticks([1e-4, 1e-3, 1e-2, 1e-1, 1, 1e1]);
|
||||
legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
@@ -387,8 +389,9 @@ plot(freqs, 1./abs(squeeze(freqresp(W3, freqs, 'Hz'))), '--', 'DisplayName', '$|
|
||||
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Magnitude');
|
||||
hold off;
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
legend('location', 'northeast', 'FontSize', 8);
|
||||
xlim([freqs(1), freqs(end)]); ylim([2e-4, 1.3e1])
|
||||
leg = legend('location', 'northeast', 'FontSize', 8);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
@@ -481,7 +484,8 @@ set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
ylim([1e-4, 20]);
|
||||
legend('location', 'northeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg = legend('location', 'northeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
@@ -573,7 +577,8 @@ xlabel('Frequency [Hz]'); ylabel('Magnitude');
|
||||
hold off;
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
ylim([1e-4, 10]);
|
||||
legend('location', 'southeast', 'FontSize', 8);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
@@ -752,19 +757,19 @@ ylim([5e-3, 5]);
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
hold on;
|
||||
plot(w, 180/pi*angle(H), 'k-');
|
||||
plot(w, 180/pi*angle(1-H), 'k--');
|
||||
plot(w, 180/pi*unwrap(angle(H)), 'k-');
|
||||
plot(w, 180/pi*unwrap(angle(1-H)), 'k--');
|
||||
hold off;
|
||||
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
||||
set(gca, 'XScale', 'log');
|
||||
yticks([-180:90:180]); ylim([-180, 180]);
|
||||
yticks([-450:90:180]); ylim([-450, 200]);
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([1e-3, 1]);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
exportFig('figs/fir_filter_ligo.pdf', 'width', 'wide', 'height', 'normal');
|
||||
exportFig('figs/fir_filter_ligo.pdf', 'width', 'wide', 'height', 'tall');
|
||||
#+end_src
|
||||
|
||||
#+name: fig:fir_filter_ligo
|
||||
@@ -828,7 +833,8 @@ xlabel('Frequency [Hz]'); ylabel('Magnitude');
|
||||
hold off;
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
ylim([1e-3, 10]);
|
||||
legend('location', 'southeast', 'FontSize', 8);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
@@ -925,7 +931,8 @@ xlabel('Frequency [Hz]'); ylabel('Magnitude');
|
||||
hold off;
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
ylim([1e-3, 10]);
|
||||
legend('location', 'southeast', 'FontSize', 8);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8);
|
||||
leg.ItemTokenSize(1) = 18;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no :exports results :results file replace
|
||||
@@ -1014,7 +1021,7 @@ addpath('./matlab');
|
||||
addpath('./matlab/src');
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :exec no
|
||||
#+begin_src matlab :eval no
|
||||
addpath('./src');
|
||||
#+end_src
|
||||
|
||||
@@ -1425,6 +1432,576 @@ xlim([freqs(1), freqs(end)]);
|
||||
#+end_src
|
||||
|
||||
|
||||
** Compare "open-loop" shaping with "close-loop" shaping
|
||||
*** Simple weights
|
||||
#+begin_src matlab
|
||||
n = 2; w0 = 2*pi*11; G0 = 1/10; G1 = 1000; Gc = 1/2;
|
||||
W1 = ((((1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (G0/Gc)^(1/n))/((1/G1)^(1/n)*(1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (1/Gc)^(1/n)))^n);
|
||||
|
||||
n = 3; w0 = 2*pi*10; G0 = 1000; G1 = 0.1; Gc = 1/2;
|
||||
W2 = ((((1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (G0/Gc)^(1/n))/((1/G1)^(1/n)*(1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (1/Gc)^(1/n)))^n);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pol = [0 W1 1;
|
||||
W2 -W1 0];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results value replace :exports results :tangle no
|
||||
sprintf('The number of states of Pol is %i', length(Pol.StateName))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: The number of states of Pol is 7
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hol, ~, gamma, ~] = hinfsyn(Pol, 1, 1,'TOLGAM', 0.001, 'METHOD', 'ric', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hol_2 = Hol;
|
||||
Hol_1 = 1 - Hol;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pcl = [0 W2 1
|
||||
W1 -W2 -1];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results value replace :exports results :tangle no
|
||||
sprintf('The number of states of Pcl is %i', length(Pcl.StateName))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: The number of states of Pcl is 8
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hcl, ~, gamma, ~] = hinfsyn(Pcl, 1, 1,'TOLGAM', 0.001, 'METHOD', 'ric', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hcl_1 = 1 - 1/(1 + Hcl);
|
||||
Hcl_2 = 1/(1 + Hcl);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports results
|
||||
size(Hol_1)
|
||||
size(Hol_2)
|
||||
size(Hcl_1)
|
||||
size(Hcl_2)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_example
|
||||
size(Hol_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hol_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hcl_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hcl_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
'org_babel_eoe'
|
||||
ans =
|
||||
'org_babel_eoe'
|
||||
#+end_example
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
freqs = logspace(-1, 3, 1000);
|
||||
|
||||
figure;
|
||||
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
|
||||
|
||||
% Magnitude
|
||||
ax1 = nexttile([2, 1]);
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_1, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_2, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_1, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_2, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
|
||||
hold off;
|
||||
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 16;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_1, freqs, 'Hz')))), '-');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_2, freqs, 'Hz')))), '-');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_1, freqs, 'Hz')))), '--');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_2, freqs, 'Hz')))), '--');
|
||||
set(gca, 'XScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
||||
hold off;
|
||||
yticks([-450:90:180]); ylim([-450, 200]);
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
#+end_src
|
||||
|
||||
*** Simple weights with LMI
|
||||
#+begin_src matlab
|
||||
n = 2; w0 = 2*pi*11; G0 = 1/10; G1 = 1000; Gc = 1/2;
|
||||
W1 = ((((1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (G0/Gc)^(1/n))/((1/G1)^(1/n)*(1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (1/Gc)^(1/n)))^n);
|
||||
|
||||
n = 3; w0 = 2*pi*10; G0 = 1000; G1 = 0.1; Gc = 1/2;
|
||||
W2 = ((((1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (G0/Gc)^(1/n))/((1/G1)^(1/n)*(1/w0)*sqrt((1-(G0/Gc)^(2/n))/(1-(Gc/G1)^(2/n)))*s + (1/Gc)^(1/n)))^n);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pol = [0 W1 1;
|
||||
W2 -W1 0];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results value replace :exports results :tangle no
|
||||
sprintf('The number of states of Pol is %i', length(Pol.StateName))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: The number of states of Pol is 7
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hol, ~, gamma, ~] = hinfsyn(Pol, 1, 1,'TOLGAM', 0.001, 'METHOD', 'lmi', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hol_2 = Hol;
|
||||
Hol_1 = 1 - Hol;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pcl = [0 W2 1
|
||||
W1 -W2 -1];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results value replace :exports results :tangle no
|
||||
sprintf('The number of states of Pcl is %i', length(Pcl.StateName))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: The number of states of Pcl is 8
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hcl, ~, gamma, ~] = hinfsyn(Pcl, 1, 1,'TOLGAM', 0.001, 'METHOD', 'lmi', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hcl_1 = 1 - 1/(1 + Hcl);
|
||||
Hcl_2 = 1/(1 + Hcl);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports results
|
||||
size(Hol_1)
|
||||
size(Hol_2)
|
||||
size(Hcl_1)
|
||||
size(Hcl_2)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_example
|
||||
size(Hol_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hol_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hcl_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
size(Hcl_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 5 states.
|
||||
'org_babel_eoe'
|
||||
ans =
|
||||
'org_babel_eoe'
|
||||
#+end_example
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
freqs = logspace(-1, 3, 1000);
|
||||
|
||||
figure;
|
||||
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
|
||||
|
||||
% Magnitude
|
||||
ax1 = nexttile([2, 1]);
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_1, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_2, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_1, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_2, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
|
||||
hold off;
|
||||
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 16;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_1, freqs, 'Hz')))), '-');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_2, freqs, 'Hz')))), '-');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_1, freqs, 'Hz')))), '--');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_2, freqs, 'Hz')))), '--');
|
||||
set(gca, 'XScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
||||
hold off;
|
||||
yticks([-450:90:180]); ylim([-450, 200]);
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
#+end_src
|
||||
|
||||
*** Complex weights
|
||||
#+begin_src matlab :exports none
|
||||
w1 = 2*pi*0.008; x1 = 0.35;
|
||||
w2 = 2*pi*0.04; x2 = 0.5;
|
||||
w3 = 2*pi*0.05; x3 = 0.5;
|
||||
|
||||
% Slope of +3 from w1
|
||||
wH = 0.008*(s^2/w1^2 + 2*x1/w1*s + 1)*(s/w1 + 1);
|
||||
% Little bump from w2 to w3
|
||||
wH = wH*(s^2/w2^2 + 2*x2/w2*s + 1)/(s^2/w3^2 + 2*x3/w3*s + 1);
|
||||
% No Slope at high frequencies
|
||||
wH = wH/(s^2/w3^2 + 2*x3/w3*s + 1)/(s/w3 + 1);
|
||||
% Little bump between w2 and w3
|
||||
w0 = 2*pi*0.045; xi = 0.1; A = 2; n = 1;
|
||||
wH = wH*((s^2 + 2*w0*xi*A^(1/n)*s + w0^2)/(s^2 + 2*w0*xi*s + w0^2))^n;
|
||||
|
||||
wH = 1/wH;
|
||||
W1 = wH;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
n = 20; Rp = 1; Wp = 2*pi*0.102;
|
||||
[b,a] = cheby1(n, Rp, Wp, 'high', 's');
|
||||
wL = 0.04*tf(a, b);
|
||||
|
||||
wL = 1/wL;
|
||||
W2 = wL;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pol = ss([0 W1 1;
|
||||
W2 -W1 0]);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pcl = ss([0 W2 1
|
||||
W1 -W2 -1]);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports results
|
||||
size(Pol)
|
||||
size(Pcl)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: size(Pol)
|
||||
: State-space model with 2 outputs, 3 inputs, and 27 states.
|
||||
: size(Pcl)
|
||||
: State-space model with 2 outputs, 3 inputs, and 27 states.
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
for iter = 1:10
|
||||
[Hol, ~, gamma, ~] = hinfsyn(Pol, 1, 1,'TOLGAM', 0.001, 'METHOD', 'ric', 'DISPLAY', 'off');
|
||||
end;
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hol_1 = 1 - Hol;
|
||||
Hol_2 = Hol;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
for iter = 1:10
|
||||
[Hcl, ~, gamma, ~] = hinfsyn(Pcl, 1, 1,'TOLGAM', 0.001, 'METHOD', 'ric', 'DISPLAY', 'off');
|
||||
end
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hcl_1 = 1 - 1/(1 + Hcl);
|
||||
Hcl_2 = 1/(1 + Hcl);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports results
|
||||
size(Hol_1)
|
||||
size(Hol_2)
|
||||
size(Hcl_1)
|
||||
size(Hcl_2)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_example
|
||||
size(Hol_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 27 states.
|
||||
size(Hol_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 27 states.
|
||||
size(Hcl_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 27 states.
|
||||
size(Hcl_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 27 states.
|
||||
'org_babel_eoe'
|
||||
ans =
|
||||
'org_babel_eoe'
|
||||
#+end_example
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
freqs = logspace(-3, 1, 1000);
|
||||
|
||||
figure;
|
||||
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
|
||||
|
||||
% Magnitude
|
||||
ax1 = nexttile([2, 1]);
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_1, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_2, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_1, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_2, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
|
||||
hold off;
|
||||
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
ylim([5e-3, 10]);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 16;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_1, freqs, 'Hz')))), '-');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_2, freqs, 'Hz')))), '-');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_1, freqs, 'Hz')))), '--');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_2, freqs, 'Hz')))), '--');
|
||||
set(gca, 'XScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
||||
hold off;
|
||||
yticks([-450:90:180]); ylim([-450, 200]);
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
#+end_src
|
||||
|
||||
*** Complex weights with alternative conf
|
||||
|
||||
#+begin_src matlab
|
||||
Pcl = ss([W1 -W1;
|
||||
0 W2;
|
||||
1 -1]);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hcl, ~, gamma, ~] = hinfsyn(Pcl, 1, 1,'TOLGAM', 0.001, 'METHOD', 'ric', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hcl_1 = 1 - 1/(1 + Hcl);
|
||||
Hcl_2 = 1/(1 + Hcl);
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
*** Complex weights with LMI
|
||||
#+begin_src matlab :exports none
|
||||
w1 = 2*pi*0.008; x1 = 0.35;
|
||||
w2 = 2*pi*0.04; x2 = 0.5;
|
||||
w3 = 2*pi*0.05; x3 = 0.5;
|
||||
|
||||
% Slope of +3 from w1
|
||||
wH = 0.008*(s^2/w1^2 + 2*x1/w1*s + 1)*(s/w1 + 1);
|
||||
% Little bump from w2 to w3
|
||||
wH = wH*(s^2/w2^2 + 2*x2/w2*s + 1)/(s^2/w3^2 + 2*x3/w3*s + 1);
|
||||
% No Slope at high frequencies
|
||||
wH = wH/(s^2/w3^2 + 2*x3/w3*s + 1)/(s/w3 + 1);
|
||||
% Little bump between w2 and w3
|
||||
w0 = 2*pi*0.045; xi = 0.1; A = 2; n = 1;
|
||||
wH = wH*((s^2 + 2*w0*xi*A^(1/n)*s + w0^2)/(s^2 + 2*w0*xi*s + w0^2))^n;
|
||||
|
||||
wH = 1/wH;
|
||||
W1 = ss(minreal(wH));
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
n = 20; Rp = 1; Wp = 2*pi*0.102;
|
||||
[b,a] = cheby1(n, Rp, Wp, 'high', 's');
|
||||
wL = 0.04*tf(a, b);
|
||||
|
||||
wL = 1/wL;
|
||||
W2 = ss(minreal(wL));
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pol = [0 W1 1;
|
||||
W2 -W1 0];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Pcl = [0 W2 1
|
||||
W1 -W2 -1];
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hol, ~, gamma, ~] = hinfsyn(Pol, 1, 1,'TOLGAM', 0.001, 'METHOD', 'lmi', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hol_1 = 1 - Hol;
|
||||
Hol_2 = Hol;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports both
|
||||
tic;
|
||||
[Hcl, ~, gamma, ~] = hinfsyn(Pcl, 1, 1,'TOLGAM', 0.001, 'METHOD', 'lmi', 'DISPLAY', 'on');
|
||||
toc;
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab
|
||||
Hcl_1 = 1 - 1/(1 + Hcl);
|
||||
Hcl_2 = 1/(1 + Hcl);
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :results output replace :exports results
|
||||
size(Hol_1)
|
||||
size(Hol_2)
|
||||
size(Hcl_1)
|
||||
size(Hcl_2)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_example
|
||||
size(Hol_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 34 states.
|
||||
size(Hol_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 34 states.
|
||||
size(Hcl_1)
|
||||
State-space model with 1 outputs, 1 inputs, and 47 states.
|
||||
size(Hcl_2)
|
||||
State-space model with 1 outputs, 1 inputs, and 47 states.
|
||||
'org_babel_eoe'
|
||||
ans =
|
||||
'org_babel_eoe'
|
||||
#+end_example
|
||||
|
||||
#+begin_src matlab :exports none
|
||||
freqs = logspace(-3, 1, 1000);
|
||||
|
||||
figure;
|
||||
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
|
||||
|
||||
% Magnitude
|
||||
ax1 = nexttile([2, 1]);
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_1, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hol_2, freqs, 'Hz'))), '-', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ OL');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_1, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_H(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, abs(squeeze(freqresp(Hcl_2, freqs, 'Hz'))), '--', ...
|
||||
'DisplayName', '$H_L(s)$ - $\mathcal{H}_\infty$ CL');
|
||||
|
||||
hold off;
|
||||
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
|
||||
ylabel('Magnitude');
|
||||
set(gca, 'XTickLabel',[]);
|
||||
ylim([5e-3, 10]);
|
||||
leg = legend('location', 'southeast', 'FontSize', 8, 'NumColumns', 2);
|
||||
leg.ItemTokenSize(1) = 16;
|
||||
|
||||
% Phase
|
||||
ax2 = nexttile;
|
||||
hold on;
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_1, freqs, 'Hz')))), '-');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hol_2, freqs, 'Hz')))), '-');
|
||||
|
||||
set(gca,'ColorOrderIndex',1);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_1, freqs, 'Hz')))), '--');
|
||||
set(gca,'ColorOrderIndex',2);
|
||||
plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(Hcl_2, freqs, 'Hz')))), '--');
|
||||
set(gca, 'XScale', 'log');
|
||||
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
|
||||
hold off;
|
||||
yticks([-450:90:180]); ylim([-450, 200]);
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([freqs(1), freqs(end)]);
|
||||
#+end_src
|
||||
|
||||
*** Conclusion
|
||||
#+begin_important
|
||||
There is no difference between " open-loop" shaping and "close-loop" shaping:
|
||||
- same " solving" time
|
||||
- same obtained filter orders
|
||||
#+end_important
|
||||
|
||||
* Impose a positive slope at DC or a negative slope at infinite frequency
|
||||
** Introduction :ignore:
|
||||
|
||||
|
Reference in New Issue
Block a user