Rename Data File, Export matlab scripts and data
This commit is contained in:
parent
c2607b8218
commit
f5bccf5f61
78
index.html
78
index.html
@ -3,7 +3,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<!-- 2019-09-10 mar. 18:15 -->
|
||||
<!-- 2019-09-10 mar. 18:18 -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Cercalo Test Bench</title>
|
||||
@ -276,28 +276,38 @@ for the JavaScript code in this tag.
|
||||
<h2>Table of Contents</h2>
|
||||
<div id="text-table-of-contents">
|
||||
<ul>
|
||||
<li><a href="#org25712dd">1. Identification</a>
|
||||
<li><a href="#org093ae95">1. Identification</a>
|
||||
<ul>
|
||||
<li><a href="#orgc595eec">1.1. Excitation Data</a></li>
|
||||
<li><a href="#orgd0be9c1">1.2. Input / Output data</a></li>
|
||||
<li><a href="#org6ef1d0f">1.3. Estimation of the Frequency Response Function Matrix</a></li>
|
||||
<li><a href="#orgb893c50">1.4. Coherence</a></li>
|
||||
<li><a href="#org57d6ee3">1.5. Extraction of a transfer function matrix</a></li>
|
||||
<li><a href="#org32d4734">1.1. Excitation Data</a></li>
|
||||
<li><a href="#org6dddc31">1.2. Input / Output data</a></li>
|
||||
<li><a href="#org9c832b5">1.3. Estimation of the Frequency Response Function Matrix</a></li>
|
||||
<li><a href="#org1036771">1.4. Coherence</a></li>
|
||||
<li><a href="#org9c60833">1.5. Extraction of a transfer function matrix</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#org6115789">2. Plant Analysis</a></li>
|
||||
<li><a href="#orgcdff0c9">3. Control</a></li>
|
||||
<li><a href="#orge7533a6">2. Plant Analysis</a></li>
|
||||
<li><a href="#org7b636db">3. Control</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org25712dd" class="outline-2">
|
||||
<h2 id="org25712dd"><span class="section-number-2">1</span> Identification</h2>
|
||||
<div id="outline-container-org093ae95" class="outline-2">
|
||||
<h2 id="org093ae95"><span class="section-number-2">1</span> Identification</h2>
|
||||
<div class="outline-text-2" id="text-1">
|
||||
<p>
|
||||
<a id="orgbba62c8"></a>
|
||||
</p>
|
||||
<div class="note">
|
||||
<p>
|
||||
All the files (data and Matlab scripts) are accessible <a href="data/plant_identification.zip">here</a>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<div id="outline-container-orgc595eec" class="outline-3">
|
||||
<h3 id="orgc595eec"><span class="section-number-3">1.1</span> Excitation Data</h3>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org32d4734" class="outline-3">
|
||||
<h3 id="org32d4734"><span class="section-number-3">1.1</span> Excitation Data</h3>
|
||||
<div class="outline-text-3" id="text-1-1">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-matlab">fs = <span class="org-highlight-numbers-number">1e4</span>;
|
||||
@ -334,15 +344,15 @@ Discrete-time zero/pole/gain model.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgd0be9c1" class="outline-3">
|
||||
<h3 id="orgd0be9c1"><span class="section-number-3">1.2</span> Input / Output data</h3>
|
||||
<div id="outline-container-org6dddc31" class="outline-3">
|
||||
<h3 id="org6dddc31"><span class="section-number-3">1.2</span> Input / Output data</h3>
|
||||
<div class="outline-text-3" id="text-1-2">
|
||||
<p>
|
||||
The identification data is loaded
|
||||
</p>
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-matlab">ux = load<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'mat/data_001.mat', 't', 'ux', 'yx', 'yy'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||
uy = load<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'mat/data_002.mat', 't', 'uy', 'yx', 'yy'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||
<pre class="src src-matlab">ux = load<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'mat/data_ux.mat', 't', 'ux', 'yx', 'yy'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||
uy = load<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'mat/data_uy.mat', 't', 'uy', 'yx', 'yy'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@ -378,7 +388,7 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
|
||||
</div>
|
||||
|
||||
|
||||
<div id="orgdd27b44" class="figure">
|
||||
<div id="orgb6e7f69" class="figure">
|
||||
<p><img src="figs/identification_ux.png" alt="identification_ux.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 1: </span>Identification signals when exciting the \(x\) axis (<a href="./figs/identification_ux.png">png</a>, <a href="./figs/identification_ux.pdf">pdf</a>)</p>
|
||||
@ -386,7 +396,7 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
|
||||
|
||||
|
||||
|
||||
<div id="orgc1aa49f" class="figure">
|
||||
<div id="org51c507d" class="figure">
|
||||
<p><img src="figs/identification_uy.png" alt="identification_uy.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 2: </span>Identification signals when exciting the \(y\) axis (<a href="./figs/identification_uy.png">png</a>, <a href="./figs/identification_uy.pdf">pdf</a>)</p>
|
||||
@ -394,8 +404,8 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-org6ef1d0f" class="outline-3">
|
||||
<h3 id="org6ef1d0f"><span class="section-number-3">1.3</span> Estimation of the Frequency Response Function Matrix</h3>
|
||||
<div id="outline-container-org9c832b5" class="outline-3">
|
||||
<h3 id="org9c832b5"><span class="section-number-3">1.3</span> Estimation of the Frequency Response Function Matrix</h3>
|
||||
<div class="outline-text-3" id="text-1-3">
|
||||
<p>
|
||||
We compute an estimate of the transfer functions.
|
||||
@ -409,7 +419,7 @@ We compute an estimate of the transfer functions.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="org26ecff4" class="figure">
|
||||
<div id="org7a99c35" class="figure">
|
||||
<p><img src="figs/frequency_response_matrix.png" alt="frequency_response_matrix.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 3: </span>Frequency Response Matrix (<a href="./figs/frequency_response_matrix.png">png</a>, <a href="./figs/frequency_response_matrix.pdf">pdf</a>)</p>
|
||||
@ -417,8 +427,8 @@ We compute an estimate of the transfer functions.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outline-container-orgb893c50" class="outline-3">
|
||||
<h3 id="orgb893c50"><span class="section-number-3">1.4</span> Coherence</h3>
|
||||
<div id="outline-container-org1036771" class="outline-3">
|
||||
<h3 id="org1036771"><span class="section-number-3">1.4</span> Coherence</h3>
|
||||
<div class="outline-text-3" id="text-1-4">
|
||||
<div class="org-src-container">
|
||||
<pre class="src src-matlab"><span class="org-rainbow-delimiters-depth-1">[</span>coh_ux_yx, f<span class="org-rainbow-delimiters-depth-1">]</span> = mscohere<span class="org-rainbow-delimiters-depth-1">(</span>ux.ux, ux.yx, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
|
||||
@ -429,7 +439,7 @@ We compute an estimate of the transfer functions.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="org2a5d4ff" class="figure">
|
||||
<div id="org7a92029" class="figure">
|
||||
<p><img src="figs/identification_coherence.png" alt="identification_coherence.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 4: </span>Coherence (<a href="./figs/identification_coherence.png">png</a>, <a href="./figs/identification_coherence.pdf">pdf</a>)</p>
|
||||
@ -438,8 +448,8 @@ We compute an estimate of the transfer functions.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="outline-container-org57d6ee3" class="outline-3">
|
||||
<h3 id="org57d6ee3"><span class="section-number-3">1.5</span> Extraction of a transfer function matrix</h3>
|
||||
<div id="outline-container-org9c60833" class="outline-3">
|
||||
<h3 id="org9c60833"><span class="section-number-3">1.5</span> Extraction of a transfer function matrix</h3>
|
||||
<div class="outline-text-3" id="text-1-5">
|
||||
<p>
|
||||
First we define the initial guess for the resonance frequencies and the weights associated.
|
||||
@ -493,7 +503,7 @@ Ignore data above some frequency.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="orgd766a83" class="figure">
|
||||
<div id="orgec6c005" class="figure">
|
||||
<p><img src="figs/weights.png" alt="weights.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 5: </span>Weights amplitude (<a href="./figs/weights.png">png</a>, <a href="./figs/weights.pdf">pdf</a>)</p>
|
||||
@ -545,7 +555,7 @@ An we run the <code>vectfit3</code> algorithm.
|
||||
</div>
|
||||
|
||||
|
||||
<div id="orgc6407a4" class="figure">
|
||||
<div id="orgc0f4949" class="figure">
|
||||
<p><img src="figs/identification_matrix_fit.png" alt="identification_matrix_fit.png" />
|
||||
</p>
|
||||
<p><span class="figure-number">Figure 6: </span>Transfer Function Extraction of the FRF matrix (<a href="./figs/identification_matrix_fit.png">png</a>, <a href="./figs/identification_matrix_fit.pdf">pdf</a>)</p>
|
||||
@ -572,16 +582,16 @@ G = <span class="org-rainbow-delimiters-depth-1">[</span>G_ux_yx, G_uy_yx;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="outline-container-org6115789" class="outline-2">
|
||||
<h2 id="org6115789"><span class="section-number-2">2</span> Plant Analysis</h2>
|
||||
<div id="outline-container-orge7533a6" class="outline-2">
|
||||
<h2 id="orge7533a6"><span class="section-number-2">2</span> Plant Analysis</h2>
|
||||
</div>
|
||||
<div id="outline-container-orgcdff0c9" class="outline-2">
|
||||
<h2 id="orgcdff0c9"><span class="section-number-2">3</span> Control</h2>
|
||||
<div id="outline-container-org7b636db" class="outline-2">
|
||||
<h2 id="org7b636db"><span class="section-number-2">3</span> Control</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div id="postamble" class="status">
|
||||
<p class="author">Author: Dehaeze Thomas</p>
|
||||
<p class="date">Created: 2019-09-10 mar. 18:15</p>
|
||||
<p class="date">Created: 2019-09-10 mar. 18:18</p>
|
||||
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
|
||||
</div>
|
||||
</body>
|
||||
|
26
index.org
26
index.org
@ -26,6 +26,28 @@
|
||||
|
||||
|
||||
* Identification
|
||||
:PROPERTIES:
|
||||
:header-args:matlab+: :tangle matlab/plant_identification.m
|
||||
:header-args:matlab+: :comments org :mkdirp yes
|
||||
:END:
|
||||
<<sec:plant_identification>>
|
||||
|
||||
** ZIP file containing the data and matlab files :ignore:
|
||||
#+begin_src bash :exports none :results none
|
||||
if [ matlab/plant_identification.m -nt data/plant_identification.zip ]; then
|
||||
cp matlab/plant_identification.m plant_identification.m;
|
||||
zip data/plant_identification \
|
||||
mat/data_ux.mat \
|
||||
mat/data_uy.mat \
|
||||
plant_identification.m
|
||||
rm plant_identification.m;
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
#+begin_note
|
||||
All the files (data and Matlab scripts) are accessible [[file:data/plant_identification.zip][here]].
|
||||
#+end_note
|
||||
|
||||
** Matlab Init :noexport:ignore:
|
||||
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
|
||||
<<matlab-dir>>
|
||||
@ -68,8 +90,8 @@ Discrete-time zero/pole/gain model.
|
||||
** Input / Output data
|
||||
The identification data is loaded
|
||||
#+begin_src matlab
|
||||
ux = load('mat/data_001.mat', 't', 'ux', 'yx', 'yy');
|
||||
uy = load('mat/data_002.mat', 't', 'uy', 'yx', 'yy');
|
||||
ux = load('mat/data_ux.mat', 't', 'ux', 'yx', 'yy');
|
||||
uy = load('mat/data_uy.mat', 't', 'uy', 'yx', 'yy');
|
||||
#+end_src
|
||||
|
||||
We remove the first seconds where the Cercalo is turned on.
|
||||
|
341
matlab/plant_identification.m
Normal file
341
matlab/plant_identification.m
Normal file
@ -0,0 +1,341 @@
|
||||
%% Clear Workspace and Close figures
|
||||
clear; close all; clc;
|
||||
|
||||
%% Intialize Laplace variable
|
||||
s = zpk('s');
|
||||
|
||||
% Excitation Data
|
||||
|
||||
fs = 1e4;
|
||||
Ts = 1/fs;
|
||||
|
||||
|
||||
|
||||
% We generate white noise with the "random number" simulink block, and we filter that noise.
|
||||
|
||||
|
||||
Gi = (1)/(1+s/2/pi/100);
|
||||
|
||||
c2d(Gi, Ts, 'tustin')
|
||||
|
||||
% Input / Output data
|
||||
% The identification data is loaded
|
||||
|
||||
ux = load('mat/data_ux.mat', 't', 'ux', 'yx', 'yy');
|
||||
uy = load('mat/data_uy.mat', 't', 'uy', 'yx', 'yy');
|
||||
|
||||
|
||||
|
||||
% We remove the first seconds where the Cercalo is turned on.
|
||||
|
||||
i0x = 20*fs;
|
||||
|
||||
i0y = 10*fs;
|
||||
|
||||
ux.t = ux.t( i0x:end) - ux.t(i0x);
|
||||
ux.ux = ux.ux(i0x:end);
|
||||
ux.yx = ux.yx(i0x:end);
|
||||
ux.yy = ux.yy(i0x:end);
|
||||
|
||||
uy.t = uy.t( i0y:end) - uy.t(i0x);
|
||||
uy.uy = uy.uy(i0y:end);
|
||||
uy.yx = uy.yx(i0y:end);
|
||||
uy.yy = uy.yy(i0y:end);
|
||||
|
||||
ux.ux = ux.ux-mean(ux.ux);
|
||||
ux.yx = ux.yx-mean(ux.yx);
|
||||
ux.yy = ux.yy-mean(ux.yy);
|
||||
|
||||
uy.ux = uy.ux-mean(uy.ux);
|
||||
uy.yx = uy.yx-mean(uy.yx);
|
||||
uy.yy = uy.yy-mean(uy.yy);
|
||||
|
||||
figure;
|
||||
ax1 = subplot(1, 2, 1);
|
||||
plot(ux.t, ux.ux);
|
||||
xlabel('Time [s]');
|
||||
ylabel('Amplitude [V]');
|
||||
legend({'$u_x$'});
|
||||
|
||||
ax2 = subplot(1, 2, 2);
|
||||
hold on;
|
||||
plot(ux.t, ux.yx, 'DisplayName', '$y_x$');
|
||||
plot(ux.t, ux.yy, 'DisplayName', '$y_y$');
|
||||
hold off;
|
||||
xlabel('Time [s]');
|
||||
ylabel('Amplitude [V]');
|
||||
legend()
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([ux.t(1), ux.t(end)])
|
||||
|
||||
|
||||
|
||||
% #+NAME: fig:identification_ux
|
||||
% #+CAPTION: Identification signals when exciting the $x$ axis ([[./figs/identification_ux.png][png]], [[./figs/identification_ux.pdf][pdf]])
|
||||
% [[file:figs/identification_ux.png]]
|
||||
|
||||
|
||||
|
||||
figure;
|
||||
ax1 = subplot(1, 2, 1);
|
||||
plot(uy.t, uy.uy);
|
||||
xlabel('Time [s]');
|
||||
ylabel('Amplitude [V]');
|
||||
legend({'$u_y$'});
|
||||
|
||||
ax2 = subplot(1, 2, 2);
|
||||
hold on;
|
||||
plot(uy.t, uy.yy, 'DisplayName', '$y_y$');
|
||||
plot(uy.t, uy.yx, 'DisplayName', '$y_x$');
|
||||
hold off;
|
||||
xlabel('Time [s]');
|
||||
ylabel('Amplitude [V]');
|
||||
legend()
|
||||
|
||||
linkaxes([ax1,ax2],'x');
|
||||
xlim([uy.t(1), uy.t(end)])
|
||||
|
||||
% Estimation of the Frequency Response Function Matrix
|
||||
% We compute an estimate of the transfer functions.
|
||||
|
||||
[tf_ux_yx, f] = tfestimate(ux.ux, ux.yx, hanning(ceil(1*fs)), [], [], fs);
|
||||
[tf_ux_yy, ~] = tfestimate(ux.ux, ux.yy, hanning(ceil(1*fs)), [], [], fs);
|
||||
[tf_uy_yx, ~] = tfestimate(uy.uy, uy.yx, hanning(ceil(1*fs)), [], [], fs);
|
||||
[tf_uy_yy, ~] = tfestimate(uy.uy, uy.yy, hanning(ceil(1*fs)), [], [], fs);
|
||||
|
||||
figure;
|
||||
ax11 = subplot(2, 2, 1);
|
||||
hold on;
|
||||
plot(f, abs(tf_ux_yx))
|
||||
title('Frequency Response Function $\frac{y_x}{u_x}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
ylabel('Amplitude')
|
||||
hold off;
|
||||
|
||||
ax12 = subplot(2, 2, 2);
|
||||
hold on;
|
||||
plot(f, abs(tf_ux_yy))
|
||||
title('Frequency Response Function $\frac{y_x}{u_y}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
hold off;
|
||||
|
||||
ax21 = subplot(2, 2, 3);
|
||||
hold on;
|
||||
plot(f, abs(tf_uy_yx))
|
||||
title('Frequency Response Function $\frac{y_y}{u_x}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
ylabel('Amplitude')
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
ax22 = subplot(2, 2, 4);
|
||||
hold on;
|
||||
plot(f, abs(tf_uy_yy))
|
||||
title('Frequency Response Function $\frac{y_y}{u_y}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
linkaxes([ax11,ax12,ax21,ax22],'x');
|
||||
xlim([10, 1000]);
|
||||
linkaxes([ax11,ax12,ax21,ax22],'y');
|
||||
ylim([1e-2, 1e3])
|
||||
|
||||
% Coherence
|
||||
|
||||
[coh_ux_yx, f] = mscohere(ux.ux, ux.yx, hanning(ceil(1*fs)), [], [], fs);
|
||||
[coh_ux_yy, ~] = mscohere(ux.ux, ux.yy, hanning(ceil(1*fs)), [], [], fs);
|
||||
[coh_uy_yx, ~] = mscohere(uy.uy, uy.yx, hanning(ceil(1*fs)), [], [], fs);
|
||||
[coh_uy_yy, ~] = mscohere(uy.uy, uy.yy, hanning(ceil(1*fs)), [], [], fs);
|
||||
|
||||
figure;
|
||||
ax11 = subplot(2, 2, 1);
|
||||
hold on;
|
||||
plot(f, coh_ux_yx)
|
||||
set(gca, 'Xscale', 'log');
|
||||
title('Coherence $\frac{y_x}{u_x}$')
|
||||
ylabel('Coherence')
|
||||
hold off;
|
||||
|
||||
ax12 = subplot(2, 2, 2);
|
||||
hold on;
|
||||
plot(f, coh_ux_yy)
|
||||
set(gca, 'Xscale', 'log');
|
||||
title('Coherence $\frac{y_x}{u_y}$')
|
||||
hold off;
|
||||
|
||||
ax21 = subplot(2, 2, 3);
|
||||
hold on;
|
||||
plot(f, coh_uy_yx)
|
||||
set(gca, 'Xscale', 'log');
|
||||
title('Coherence $\frac{y_y}{u_x}$')
|
||||
ylabel('Coherence')
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
ax22 = subplot(2, 2, 4);
|
||||
hold on;
|
||||
plot(f, coh_uy_yy)
|
||||
set(gca, 'Xscale', 'log');
|
||||
title('Coherence $\frac{y_y}{u_y}$')
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
linkaxes([ax11,ax12,ax21,ax22],'x');
|
||||
xlim([10, 1000]);
|
||||
linkaxes([ax11,ax12,ax21,ax22],'y');
|
||||
ylim([0, 1])
|
||||
|
||||
% Extraction of a transfer function matrix
|
||||
% First we define the initial guess for the resonance frequencies and the weights associated.
|
||||
|
||||
freqs_res = [410, 250]; % [Hz]
|
||||
freqs_res_weights = [10, 10]; % [Hz]
|
||||
|
||||
|
||||
|
||||
% From the number of resonance frequency we want to fit, we define the order =N= of the system we want to obtain.
|
||||
|
||||
N = 2*length(freqs_res);
|
||||
|
||||
|
||||
|
||||
% We then make an initial guess on the complex values of the poles.
|
||||
|
||||
xi = 0.001; % Approximate modal damping
|
||||
poles = [2*pi*freqs_res*(xi + 1i), 2*pi*freqs_res*(xi - 1i)];
|
||||
|
||||
|
||||
|
||||
% We then define the weight that will be used for the fitting.
|
||||
% Basically, we want more weight around the resonance and at low frequency (below the first resonance).
|
||||
% Also, we want more importance where we have a better coherence.
|
||||
|
||||
weight = ones(1, length(f));
|
||||
% weight = G_coh';
|
||||
|
||||
% alpha = 0.1;
|
||||
|
||||
% for freq_i = 1:length(freqs_res)
|
||||
% weight(f>(1-alpha)*freqs_res(freq_i) & omega<(1 + alpha)*2*pi*freqs_res(freq_i)) = freqs_res_weights(freq_i);
|
||||
% end
|
||||
|
||||
|
||||
|
||||
% Ignore data above some frequency.
|
||||
|
||||
weight(f>1000) = 0;
|
||||
|
||||
figure;
|
||||
hold on;
|
||||
plot(f, weight);
|
||||
plot(freqs_res, ones(size(freqs_res)), 'rx');
|
||||
hold off;
|
||||
xlabel('Frequency [Hz]');
|
||||
xlabel('Weight Amplitude');
|
||||
set(gca, 'xscale', 'log');
|
||||
xlim([f(1), f(end)]);
|
||||
|
||||
|
||||
|
||||
% #+NAME: fig:weights
|
||||
% #+CAPTION: Weights amplitude ([[./figs/weights.png][png]], [[./figs/weights.pdf][pdf]])
|
||||
% [[file:figs/weights.png]]
|
||||
|
||||
% When we set some options for =vfit3=.
|
||||
|
||||
opts = struct();
|
||||
|
||||
opts.stable = 1; % Enforce stable poles
|
||||
opts.asymp = 1; % Force D matrix to be null
|
||||
opts.relax = 1; % Use vector fitting with relaxed non-triviality constraint
|
||||
opts.skip_pole = 0; % Do NOT skip pole identification
|
||||
opts.skip_res = 0; % Do NOT skip identification of residues (C,D,E)
|
||||
opts.cmplx_ss = 0; % Create real state space model with block diagonal A
|
||||
|
||||
opts.spy1 = 0; % No plotting for first stage of vector fitting
|
||||
opts.spy2 = 0; % Create magnitude plot for fitting of f(s)
|
||||
|
||||
|
||||
|
||||
% We define the number of iteration.
|
||||
|
||||
Niter = 5;
|
||||
|
||||
|
||||
|
||||
% An we run the =vectfit3= algorithm.
|
||||
|
||||
for iter = 1:Niter
|
||||
[SER_ux_yx, poles, ~, fit_ux_yx] = vectfit3(tf_ux_yx.', 1i*2*pi*f, poles, weight, opts);
|
||||
end
|
||||
for iter = 1:Niter
|
||||
[SER_uy_yx, poles, ~, fit_uy_yx] = vectfit3(tf_uy_yx.', 1i*2*pi*f, poles, weight, opts);
|
||||
end
|
||||
for iter = 1:Niter
|
||||
[SER_ux_yy, poles, ~, fit_ux_yy] = vectfit3(tf_ux_yy.', 1i*2*pi*f, poles, weight, opts);
|
||||
end
|
||||
for iter = 1:Niter
|
||||
[SER_uy_yy, poles, ~, fit_uy_yy] = vectfit3(tf_uy_yy.', 1i*2*pi*f, poles, weight, opts);
|
||||
end
|
||||
|
||||
figure;
|
||||
ax11 = subplot(2, 2, 1);
|
||||
hold on;
|
||||
plot(f, abs(tf_ux_yx))
|
||||
plot(f, abs(fit_ux_yx))
|
||||
title('Frequency Response Function $\frac{y_x}{u_x}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
ylabel('Amplitude')
|
||||
hold off;
|
||||
|
||||
ax12 = subplot(2, 2, 2);
|
||||
hold on;
|
||||
plot(f, abs(tf_ux_yy))
|
||||
plot(f, abs(fit_ux_yy))
|
||||
title('Frequency Response Function $\frac{y_x}{u_y}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
hold off;
|
||||
|
||||
ax21 = subplot(2, 2, 3);
|
||||
hold on;
|
||||
plot(f, abs(tf_uy_yx))
|
||||
plot(f, abs(fit_uy_yx))
|
||||
title('Frequency Response Function $\frac{y_y}{u_x}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
ylabel('Amplitude')
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
ax22 = subplot(2, 2, 4);
|
||||
hold on;
|
||||
plot(f, abs(tf_uy_yy))
|
||||
plot(f, abs(fit_uy_yy))
|
||||
title('Frequency Response Function $\frac{y_y}{u_y}$')
|
||||
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
|
||||
xlabel('Frequency [Hz]')
|
||||
hold off;
|
||||
|
||||
linkaxes([ax11,ax12,ax21,ax22],'x');
|
||||
xlim([10, 1000]);
|
||||
linkaxes([ax11,ax12,ax21,ax22],'y');
|
||||
ylim([1e-2, 1e3])
|
||||
|
||||
|
||||
|
||||
% #+NAME: fig:identification_matrix_fit
|
||||
% #+CAPTION: Transfer Function Extraction of the FRF matrix ([[./figs/identification_matrix_fit.png][png]], [[./figs/identification_matrix_fit.pdf][pdf]])
|
||||
% [[file:figs/identification_matrix_fit.png]]
|
||||
|
||||
% And finally, we create the identified state space model:
|
||||
|
||||
G_ux_yx = minreal(ss(full(SER_ux_yx.A),SER_ux_yx.B,SER_ux_yx.C,SER_ux_yx.D));
|
||||
G_uy_yx = minreal(ss(full(SER_uy_yx.A),SER_uy_yx.B,SER_uy_yx.C,SER_uy_yx.D));
|
||||
G_ux_yy = minreal(ss(full(SER_ux_yy.A),SER_ux_yy.B,SER_ux_yy.C,SER_ux_yy.D));
|
||||
G_uy_yy = minreal(ss(full(SER_uy_yy.A),SER_uy_yy.B,SER_uy_yy.C,SER_uy_yy.D));
|
||||
|
||||
G = [G_ux_yx, G_uy_yx;
|
||||
G_ux_yy, G_uy_yy];
|
||||
|
||||
save('mat/plant.mat', 'G');
|
Loading…
Reference in New Issue
Block a user