Update Matlab tangled files
This commit is contained in:
1 parent
8f121be23b
commit
8e08e3f3d4
10 files changed
+159
-121
No files matched your search
+46
-18
@@ -45,7 +45,7 @@ To run the Matlab code, go in the =matlab= directory and run the following Matla
|
||||
|
||||
#+caption: Paper's sections and corresponding Matlab files
|
||||
| Sections | Matlab File |
|
||||
|------------------------------------+----------------------------|
|
||||
|------------------------------------+--------------------------|
|
||||
| Section [[sec:system_description]] | =s1_system_description.m= |
|
||||
| Section [[sec:iff_pure_int]] | =s2_iff_pure_int.m= |
|
||||
| Section [[sec:iff_pseudo_int]] | =s3_iff_hpf.m= |
|
||||
@@ -67,9 +67,12 @@ To run the Matlab code, go in the =matlab= directory and run the following Matla
|
||||
<<matlab-init>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no
|
||||
addpath('./matlab/');
|
||||
addpath('./src/');
|
||||
#+begin_src matlab :tangle no :noweb yes
|
||||
<<m-init-path>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :eval no :noweb yes
|
||||
<<m-init-path-tangle>>
|
||||
#+end_src
|
||||
|
||||
** System description
|
||||
@@ -447,9 +450,12 @@ Two identical controllers $K_F$ are used to feedback each of the sensed force to
|
||||
<<matlab-init>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no
|
||||
addpath('./matlab/');
|
||||
addpath('./src/');
|
||||
#+begin_src matlab :tangle no :noweb yes
|
||||
<<m-init-path>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :eval no :noweb yes
|
||||
<<m-init-path-tangle>>
|
||||
#+end_src
|
||||
|
||||
** Plant Parameters
|
||||
@@ -771,9 +777,12 @@ It is shown that for non-null rotating speed, one pole is bound to the right-hal
|
||||
<<matlab-init>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no
|
||||
addpath('./matlab/');
|
||||
addpath('./src/');
|
||||
#+begin_src matlab :tangle no :noweb yes
|
||||
<<m-init-path>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :eval no :noweb yes
|
||||
<<m-init-path-tangle>>
|
||||
#+end_src
|
||||
|
||||
** Plant Parameters
|
||||
@@ -1167,9 +1176,12 @@ To find the optimum, the gain that maximize the simultaneous damping of the mode
|
||||
<<matlab-init>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no
|
||||
addpath('./matlab/');
|
||||
addpath('./src/');
|
||||
#+begin_src matlab :tangle no :noweb yes
|
||||
<<m-init-path>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :eval no :noweb yes
|
||||
<<m-init-path-tangle>>
|
||||
#+end_src
|
||||
|
||||
** Schematic
|
||||
@@ -1768,9 +1780,12 @@ These two methods are now compared in terms of added damping, closed-loop compli
|
||||
<<matlab-init>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :tangle no
|
||||
addpath('./matlab/');
|
||||
addpath('./src/');
|
||||
#+begin_src matlab :tangle no :noweb yes
|
||||
<<m-init-path>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src matlab :eval no :noweb yes
|
||||
<<m-init-path-tangle>>
|
||||
#+end_src
|
||||
|
||||
** Plant Parameters
|
||||
@@ -2143,10 +2158,23 @@ Critical Damping corresponds to to $\xi = 1$, and thus:
|
||||
#+latex: \printbibliography
|
||||
bibliography:ref.bib
|
||||
|
||||
* Helping Functions :noexport:
|
||||
** Initialize Path
|
||||
#+NAME: m-init-path
|
||||
#+BEGIN_SRC matlab
|
||||
addpath('./matlab/'); % Path for scripts
|
||||
addpath('./matlab/src/'); % Path for functions
|
||||
#+END_SRC
|
||||
|
||||
#+NAME: m-init-path-tangle
|
||||
#+BEGIN_SRC matlab
|
||||
addpath('./src/'); % Path for functions
|
||||
#+END_SRC
|
||||
|
||||
* Functions :noexport:
|
||||
** Sort Poles for the Root Locus
|
||||
:PROPERTIES:
|
||||
:header-args:matlab+: :tangle src/rootLocusPolesSorted.m
|
||||
:header-args:matlab+: :tangle matlab/src/rootLocusPolesSorted.m
|
||||
:header-args:matlab+: :comments none :mkdirp yes :eval no
|
||||
:END:
|
||||
<<sec:rootLocusPolesSorted>>
|
||||
@@ -2291,7 +2319,7 @@ This Matlab function is accessible [[file:src/rootLocusPolesSorted.m][here]].
|
||||
#+end_src
|
||||
|
||||
** =computeSimultaneousDamping=
|
||||
#+begin_src matlab :tangle src/computeSimultaneousDamping.m
|
||||
#+begin_src matlab :tangle matlab/src/computeSimultaneousDamping.m
|
||||
function [xi_min] = computeSimultaneousDamping(g, G, K)
|
||||
[w, xi] = damp(minreal(feedback(G, g*K)));
|
||||
xi_min = 1/min(xi);
|
||||
|
||||
@@ -4,6 +4,8 @@ clear; close all; clc;
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
addpath('./src/'); % Path for functions
|
||||
|
||||
% Numerical Values
|
||||
% Let's define initial values for the model.
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ clear; close all; clc;
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
addpath('./src/'); % Path for functions
|
||||
|
||||
% Plant Parameters
|
||||
% Let's define initial values for the model.
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ clear; close all; clc;
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
addpath('./src/'); % Path for functions
|
||||
|
||||
% Plant Parameters
|
||||
% Let's define initial values for the model.
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ clear; close all; clc;
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
addpath('./src/'); % Path for functions
|
||||
|
||||
% Plant Parameters
|
||||
% Let's define initial values for the model.
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ clear; close all; clc;
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
addpath('./src/'); % Path for functions
|
||||
|
||||
% Plant Parameters
|
||||
% Let's define initial values for the model.
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
% =computeSimultaneousDamping=
|
||||
|
||||
function [xi_min] = computeSimultaneousDamping(g, G, K)
|
||||
[w, xi] = damp(minreal(feedback(G, g*K)));
|
||||
xi_min = 1/min(xi);
|
||||
|
||||
if xi_min < 0
|
||||
xi_min = 1e8;
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,93 @@
|
||||
function [poles] = rootLocusPolesSorted(G, K, gains, args)
|
||||
% rootLocusPolesSorted -
|
||||
%
|
||||
% Syntax: [poles] = rootLocusPolesSorted(G, K, gains, args)
|
||||
%
|
||||
% Inputs:
|
||||
% - G, K, gains, args -
|
||||
%
|
||||
% Outputs:
|
||||
% - poles -
|
||||
|
||||
arguments
|
||||
G
|
||||
K
|
||||
gains
|
||||
args.minreal double {mustBeNumericOrLogical} = false
|
||||
args.p_half double {mustBeNumericOrLogical} = false
|
||||
args.d_max double {mustBeNumeric} = -1
|
||||
end
|
||||
|
||||
if args.minreal
|
||||
p1 = pole(minreal(feedback(G, gains(1)*K)));
|
||||
[~, i_uniq] = uniquetol([real(p1), imag(p1)], 1e-10, 'ByRows', true);
|
||||
p1 = p1(i_uniq);
|
||||
|
||||
poles = zeros(length(p1), length(gains));
|
||||
poles(:, 1) = p1;
|
||||
else
|
||||
p1 = pole(feedback(G, gains(1)*K));
|
||||
[~, i_uniq] = uniquetol([real(p1), imag(p1)], 1e-10, 'ByRows', true);
|
||||
p1 = p1(i_uniq);
|
||||
|
||||
poles = zeros(length(p1), length(gains));
|
||||
poles(:, 1) = p1;
|
||||
end
|
||||
|
||||
if args.minreal
|
||||
p2 = pole(minreal(feedback(G, gains(2)*K)));
|
||||
[~, i_uniq] = uniquetol([real(p2), imag(p2)], 1e-10, 'ByRows', true);
|
||||
p2 = p2(i_uniq);
|
||||
poles(:, 2) = p2;
|
||||
else
|
||||
p2 = pole(feedback(G, gains(2)*K));
|
||||
[~, i_uniq] = uniquetol([real(p2), imag(p2)], 1e-10, 'ByRows', true);
|
||||
p2 = p2(i_uniq);
|
||||
poles(:, 2) = p2;
|
||||
end
|
||||
|
||||
for g_i = 3:length(gains)
|
||||
% Estimated value of the poles
|
||||
poles_est = poles(:, g_i-1) + (poles(:, g_i-1) - poles(:, g_i-2))*(gains(g_i) - gains(g_i-1))/(gains(g_i-1) - gains(g_i - 2));
|
||||
|
||||
% New values for the poles
|
||||
poles_gi = pole(feedback(G, gains(g_i)*K));
|
||||
[~, i_uniq] = uniquetol([real(poles_gi), imag(poles_gi)], 1e-10, 'ByRows', true);
|
||||
poles_gi = poles_gi(i_uniq);
|
||||
|
||||
% Array of distances between all the poles
|
||||
poles_dist = sqrt((poles_est-poles_gi.').*conj(poles_est-poles_gi.'));
|
||||
|
||||
% Get indices corresponding to distances from lowest to highest
|
||||
[~, c] = sort(min(poles_dist));
|
||||
|
||||
as = 1:length(poles_gi);
|
||||
|
||||
% for each column of poles_dist corresponding to the i'th pole
|
||||
% with closest previous poles
|
||||
for p_i = c
|
||||
% Get the indice a_i of the previous pole that is the closest
|
||||
% to pole c(p_i)
|
||||
[~, a_i] = min(poles_dist(:, p_i));
|
||||
|
||||
poles(as(a_i), g_i) = poles_gi(p_i);
|
||||
|
||||
% Remove old poles that are already matched
|
||||
% poles_gi(as(a_i), :) = [];
|
||||
poles_dist(a_i, :) = [];
|
||||
as(a_i) = [];
|
||||
end
|
||||
end
|
||||
|
||||
if args.d_max > 0
|
||||
poles = poles(max(abs(poles(:, 2:end) - poles(:, 1:end-1))') > args.d_max, :);
|
||||
end
|
||||
|
||||
if args.p_half
|
||||
poles = poles(1:round(end/2), :);
|
||||
end
|
||||
|
||||
[~, s_p] = sort(imag(poles(:,1)), 'descend');
|
||||
poles = poles(s_p, :);
|
||||
|
||||
poles = poles.';
|
||||
@@ -1,10 +0,0 @@
|
||||
% =computeSimultaneousDamping=
|
||||
|
||||
function [xi_min] = computeSimultaneousDamping(g, G, K)
|
||||
[w, xi] = damp(minreal(feedback(G, g*K)));
|
||||
xi_min = 1/min(xi);
|
||||
|
||||
if xi_min < 0
|
||||
xi_min = 1e8;
|
||||
end
|
||||
end
|
||||
@@ -1,93 +0,0 @@
|
||||
function [poles] = rootLocusPolesSorted(G, K, gains, args)
|
||||
% rootLocusPolesSorted -
|
||||
%
|
||||
% Syntax: [poles] = rootLocusPolesSorted(G, K, gains, args)
|
||||
%
|
||||
% Inputs:
|
||||
% - G, K, gains, args -
|
||||
%
|
||||
% Outputs:
|
||||
% - poles -
|
||||
|
||||
arguments
|
||||
G
|
||||
K
|
||||
gains
|
||||
args.minreal double {mustBeNumericOrLogical} = false
|
||||
args.p_half double {mustBeNumericOrLogical} = false
|
||||
args.d_max double {mustBeNumeric} = -1
|
||||
end
|
||||
|
||||
if args.minreal
|
||||
p1 = pole(minreal(feedback(G, gains(1)*K)));
|
||||
[~, i_uniq] = uniquetol([real(p1), imag(p1)], 1e-10, 'ByRows', true);
|
||||
p1 = p1(i_uniq);
|
||||
|
||||
poles = zeros(length(p1), length(gains));
|
||||
poles(:, 1) = p1;
|
||||
else
|
||||
p1 = pole(feedback(G, gains(1)*K));
|
||||
[~, i_uniq] = uniquetol([real(p1), imag(p1)], 1e-10, 'ByRows', true);
|
||||
p1 = p1(i_uniq);
|
||||
|
||||
poles = zeros(length(p1), length(gains));
|
||||
poles(:, 1) = p1;
|
||||
end
|
||||
|
||||
if args.minreal
|
||||
p2 = pole(minreal(feedback(G, gains(2)*K)));
|
||||
[~, i_uniq] = uniquetol([real(p2), imag(p2)], 1e-10, 'ByRows', true);
|
||||
p2 = p2(i_uniq);
|
||||
poles(:, 2) = p2;
|
||||
else
|
||||
p2 = pole(feedback(G, gains(2)*K));
|
||||
[~, i_uniq] = uniquetol([real(p2), imag(p2)], 1e-10, 'ByRows', true);
|
||||
p2 = p2(i_uniq);
|
||||
poles(:, 2) = p2;
|
||||
end
|
||||
|
||||
for g_i = 3:length(gains)
|
||||
% Estimated value of the poles
|
||||
poles_est = poles(:, g_i-1) + (poles(:, g_i-1) - poles(:, g_i-2))*(gains(g_i) - gains(g_i-1))/(gains(g_i-1) - gains(g_i - 2));
|
||||
|
||||
% New values for the poles
|
||||
poles_gi = pole(feedback(G, gains(g_i)*K));
|
||||
[~, i_uniq] = uniquetol([real(poles_gi), imag(poles_gi)], 1e-10, 'ByRows', true);
|
||||
poles_gi = poles_gi(i_uniq);
|
||||
|
||||
% Array of distances between all the poles
|
||||
poles_dist = sqrt((poles_est-poles_gi.').*conj(poles_est-poles_gi.'));
|
||||
|
||||
% Get indices corresponding to distances from lowest to highest
|
||||
[~, c] = sort(min(poles_dist));
|
||||
|
||||
as = 1:length(poles_gi);
|
||||
|
||||
% for each column of poles_dist corresponding to the i'th pole
|
||||
% with closest previous poles
|
||||
for p_i = c
|
||||
% Get the indice a_i of the previous pole that is the closest
|
||||
% to pole c(p_i)
|
||||
[~, a_i] = min(poles_dist(:, p_i));
|
||||
|
||||
poles(as(a_i), g_i) = poles_gi(p_i);
|
||||
|
||||
% Remove old poles that are already matched
|
||||
% poles_gi(as(a_i), :) = [];
|
||||
poles_dist(a_i, :) = [];
|
||||
as(a_i) = [];
|
||||
end
|
||||
end
|
||||
|
||||
if args.d_max > 0
|
||||
poles = poles(max(abs(poles(:, 2:end) - poles(:, 1:end-1))') > args.d_max, :);
|
||||
end
|
||||
|
||||
if args.p_half
|
||||
poles = poles(1:round(end/2), :);
|
||||
end
|
||||
|
||||
[~, s_p] = sort(imag(poles(:,1)), 'descend');
|
||||
poles = poles(s_p, :);
|
||||
|
||||
poles = poles.';
|
||||
Reference in new issue
Block a user