Update html

This commit is contained in:
Thomas Dehaeze 2020-11-12 10:22:39 +01:00
parent 9c1d16e11a
commit acb1b5b068

View File

@ -3,17 +3,13 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2020-11-11 mer. 13:53 -->
<!-- 2020-11-12 jeu. 10:22 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Spectral Analysis using Matlab</title>
<meta name="generator" content="Org mode" />
<meta name="author" content="Dehaeze Thomas" />
<link rel="stylesheet" type="text/css" href="./css/htmlize.css"/>
<link rel="stylesheet" type="text/css" href="./css/readtheorg.css"/>
<link rel="stylesheet" type="text/css" href="./css/custom.css"/>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/readtheorg.js"></script>
<link rel="stylesheet" type="text/css" href="https://research.tdehaeze.xyz/css/style.css"/>
<script type="text/javascript" src="https://research.tdehaeze.xyz/js/script.js"></script>
<script>MathJax = {
tex: {
tags: 'ams',
@ -34,43 +30,43 @@
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org088a1b1">1. Spectral Analysis - Basics</a>
<li><a href="#org83eb340">1. Spectral Analysis - Basics</a>
<ul>
<li><a href="#orgd737eb1">1.1. Sensitivity of the instrumentation</a></li>
<li><a href="#org560596c">1.2. Convert the time domain from volts to velocity</a></li>
<li><a href="#orgec36aea">1.3. Power Spectral Density and Amplitude Spectral Density</a></li>
<li><a href="#org02a257a">1.4. Modification of a signal&rsquo;s Power Spectral Density when going through an LTI system</a></li>
<li><a href="#orgdcf3ecc">1.5. From PSD of the velocity to the PSD of the displacement</a></li>
<li><a href="#org4c5249b">1.6. Cumulative Power/Amplitude Spectrum</a></li>
<li><a href="#orgfd9ad08">1.1. Sensitivity of the instrumentation</a></li>
<li><a href="#org85420e8">1.2. Convert the time domain from volts to velocity</a></li>
<li><a href="#orgfc7a027">1.3. Power Spectral Density and Amplitude Spectral Density</a></li>
<li><a href="#org37d02a0">1.4. Modification of a signal&rsquo;s Power Spectral Density when going through an LTI system</a></li>
<li><a href="#orgdf16414">1.5. From PSD of the velocity to the PSD of the displacement</a></li>
<li><a href="#orgc31de97">1.6. Cumulative Power/Amplitude Spectrum</a></li>
</ul>
</li>
<li><a href="#org2810914">2. Time domain signal that approximate a PSD - TF technique</a>
<li><a href="#org0112edc">2. Time domain signal that approximate a PSD - TF technique</a>
<ul>
<li><a href="#org1a03b54">2.1. Signal&rsquo;s PSD</a></li>
<li><a href="#orgae722c1">2.2. Transfer Function that approximate the ASD</a></li>
<li><a href="#org0c62275">2.3. Generated Time domain signal</a></li>
<li><a href="#org3713bc7">2.4. Comparison of the Power Spectral Densities</a></li>
<li><a href="#org35debdf">2.5. Simulink</a></li>
<li><a href="#orgd84f6cb">2.1. Signal&rsquo;s PSD</a></li>
<li><a href="#org347dfb3">2.2. Transfer Function that approximate the ASD</a></li>
<li><a href="#org65665fc">2.3. Generated Time domain signal</a></li>
<li><a href="#org2b2326f">2.4. Comparison of the Power Spectral Densities</a></li>
<li><a href="#orgbce7f0e">2.5. Simulink</a></li>
</ul>
</li>
<li><a href="#org00702f7">3. Time domain signal that approximate a PSD - IFFT technique</a>
<li><a href="#org56d1b86">3. Time domain signal that approximate a PSD - IFFT technique</a>
<ul>
<li><a href="#org1700082">3.1. Signal&rsquo;s PSD</a></li>
<li><a href="#org4ce31b2">3.2. Algorithm</a></li>
<li><a href="#orga9ef28c">3.3. Obtained Time Domain Signal</a></li>
<li><a href="#org92e1c44">3.4. PSD Comparison</a></li>
<li><a href="#org5fd81fb">3.1. Signal&rsquo;s PSD</a></li>
<li><a href="#org04e5156">3.2. Algorithm</a></li>
<li><a href="#org090de25">3.3. Obtained Time Domain Signal</a></li>
<li><a href="#org8798466">3.4. PSD Comparison</a></li>
</ul>
</li>
<li><a href="#orgce7f3a9">4. Compute the Noise level and Signal level from PSD</a>
<li><a href="#org11ee648">4. Compute the Noise level and Signal level from PSD</a>
<ul>
<li><a href="#org57f2f45">4.1. Time Domain Signal</a></li>
<li><a href="#org3f32ef0">4.2. Estimation of the magnitude of a deterministic signal</a></li>
<li><a href="#org5ab6d13">4.3. Estimation of the noise level</a></li>
<li><a href="#orgf5f2a97">4.1. Time Domain Signal</a></li>
<li><a href="#org54820b0">4.2. Estimation of the magnitude of a deterministic signal</a></li>
<li><a href="#orgb8e3ada">4.3. Estimation of the noise level</a></li>
</ul>
</li>
<li><a href="#orgda903f8">5. Further Notes</a>
<li><a href="#org2405c66">5. Further Notes</a>
<ul>
<li><a href="#orge7125fc">5.1. PSD of ADC quantization noise</a></li>
<li><a href="#org6ea3373">5.1. PSD of ADC quantization noise</a></li>
</ul>
</li>
</ul>
@ -86,30 +82,24 @@ Some matlab documentation about Spectral Analysis can be found <a href="https://
</p>
<p>
First, in section <a href="#orgfea9539">1</a>, some basics of spectral analysis are presented.
First, in section <a href="#org89287c1">1</a>, some basics of spectral analysis are presented.
</p>
<p>
In some cases, we want to generate a time domain signal with defined Power Spectral Density.
Two methods are presented in sections <a href="#org1401958">2</a> and <a href="#org8fad482">3</a>.
Two methods are presented in sections <a href="#org35aba27">2</a> and <a href="#orgb97846a">3</a>.
</p>
<p>
Finally, some notes are done on how to compute the noise level and signal level from a given Power Spectral Density in section <a href="#orgb30a0a4">4</a>.
Finally, some notes are done on how to compute the noise level and signal level from a given Power Spectral Density in section <a href="#orgcd3ff15">4</a>.
</p>
<div id="outline-container-org088a1b1" class="outline-2">
<h2 id="org088a1b1"><span class="section-number-2">1</span> Spectral Analysis - Basics</h2>
<div id="outline-container-org83eb340" class="outline-2">
<h2 id="org83eb340"><span class="section-number-2">1</span> Spectral Analysis - Basics</h2>
<div class="outline-text-2" id="text-1">
<p>
<a id="orgfea9539"></a>
<a id="org89287c1"></a>
</p>
<div class="note" id="orgc42d320">
<p>
All the files (data and Matlab scripts) are accessible <a href="data/spectral_analysis_basics.zip">here</a>.
</p>
</div>
<p>
In this section, the basics of spectral analysis is presented with the associated Matlab commands.
</p>
@ -124,11 +114,11 @@ This include:
</ul>
</div>
<div id="outline-container-orgd737eb1" class="outline-3">
<h3 id="orgd737eb1"><span class="section-number-3">1.1</span> Sensitivity of the instrumentation</h3>
<div id="outline-container-orgfd9ad08" class="outline-3">
<h3 id="orgfd9ad08"><span class="section-number-3">1.1</span> Sensitivity of the instrumentation</h3>
<div class="outline-text-3" id="text-1-1">
<p>
A typical measurement setup is shown in figure <a href="#org1b35d9b">1</a> where we measure a physical signal which is here a velocity \(v(t)\) using a geophone.
A typical measurement setup is shown in figure <a href="#orgb74cd65">1</a> where we measure a physical signal which is here a velocity \(v(t)\) using a geophone.
The geophone has some dynamics that we represent with \(G_g(s)\), its output a voltage.
The output of the geophone is then amplified by a voltage amplifier with a transfer function \(G_a(s)\).
</p>
@ -142,7 +132,7 @@ To obtain the real physical quantity \(v(t)\) as measured by the sensor from the
</p>
<div id="org1b35d9b" class="figure">
<div id="orgb74cd65" class="figure">
<p><img src="figs/velocity_to_voltage.png" alt="velocity_to_voltage.png" />
</p>
<p><span class="figure-number">Figure 1: </span>Schematic of the instrumentation used for the measurement</p>
@ -174,15 +164,15 @@ And the dynamics of the amplifier in the bandwidth of interest is just a gain: \
</div>
</div>
<div id="outline-container-org560596c" class="outline-3">
<h3 id="org560596c"><span class="section-number-3">1.2</span> Convert the time domain from volts to velocity</h3>
<div id="outline-container-org85420e8" class="outline-3">
<h3 id="org85420e8"><span class="section-number-3">1.2</span> Convert the time domain from volts to velocity</h3>
<div class="outline-text-3" id="text-1-2">
<p>
Let&rsquo;s here try to obtain the time domain signal \(v(t)\) from the measurement \(x\).
</p>
<p>
If \({G_a(s)}^{-1} {G_g(s)}^{-1}\) is proper, we can simulate this dynamical system to go from the voltage \(x\) to the velocity \(v\) as shown in figure <a href="#org5e194c0">2</a>.
If \({G_a(s)}^{-1} {G_g(s)}^{-1}\) is proper, we can simulate this dynamical system to go from the voltage \(x\) to the velocity \(v\) as shown in figure <a href="#org30ad609">2</a>.
</p>
<p>
@ -190,7 +180,7 @@ If \({G_a(s)}^{-1} {G_g(s)}^{-1}\) is not proper, we add low pass filters at hig
</p>
<div id="org5e194c0" class="figure">
<div id="org30ad609" class="figure">
<p><img src="figs/voltage_to_velocity.png" alt="voltage_to_velocity.png" />
</p>
<p><span class="figure-number">Figure 2: </span>Schematic of the instrumentation used for the measurement</p>
@ -223,7 +213,7 @@ We simulate this system with matlab using the <code>lsim</code> command.
And we plot the obtained velocity
</p>
<div id="org47a11c9" class="figure">
<div id="org977b03c" class="figure">
<p><img src="figs/velocity_time.png" alt="velocity_time.png" />
</p>
<p><span class="figure-number">Figure 3: </span>Computed Velocity from the measured Voltage</p>
@ -231,8 +221,8 @@ And we plot the obtained velocity
</div>
</div>
<div id="outline-container-orgec36aea" class="outline-3">
<h3 id="orgec36aea"><span class="section-number-3">1.3</span> Power Spectral Density and Amplitude Spectral Density</h3>
<div id="outline-container-orgfc7a027" class="outline-3">
<h3 id="orgfc7a027"><span class="section-number-3">1.3</span> Power Spectral Density and Amplitude Spectral Density</h3>
<div class="outline-text-3" id="text-1-3">
<p>
From the Matlab documentation:
@ -300,25 +290,25 @@ Then, compute the power spectral density \(S_v\) and the associated frequency ve
</div>
<p>
The obtained PSD is shown in figure <a href="#org343c5aa">4</a>.
The obtained PSD is shown in figure <a href="#org9a6205d">4</a>.
</p>
<div id="org343c5aa" class="figure">
<div id="org9a6205d" class="figure">
<p><img src="figs/psd_velocity.png" alt="psd_velocity.png" />
</p>
<p><span class="figure-number">Figure 4: </span>Power Spectral Density of the measured velocity</p>
</div>
<p>
The Amplitude Spectral Density (ASD) is defined as the square root of the Power Spectral Density and is shown in figure <a href="#org5511b28">5</a>.
The Amplitude Spectral Density (ASD) is defined as the square root of the Power Spectral Density and is shown in figure <a href="#org243bdeb">5</a>.
</p>
\begin{equation}
\Gamma_{vv}(f) = \sqrt{S_{vv}(f)} \quad \left[ \frac{m/s}{\sqrt{Hz}} \right]
\end{equation}
<div id="org5511b28" class="figure">
<div id="org243bdeb" class="figure">
<p><img src="figs/asd_velocity.png" alt="asd_velocity.png" />
</p>
<p><span class="figure-number">Figure 5: </span>Power Spectral Density of the measured velocity</p>
@ -326,22 +316,22 @@ The Amplitude Spectral Density (ASD) is defined as the square root of the Power
</div>
</div>
<div id="outline-container-org02a257a" class="outline-3">
<h3 id="org02a257a"><span class="section-number-3">1.4</span> Modification of a signal&rsquo;s Power Spectral Density when going through an LTI system</h3>
<div id="outline-container-org37d02a0" class="outline-3">
<h3 id="org37d02a0"><span class="section-number-3">1.4</span> Modification of a signal&rsquo;s Power Spectral Density when going through an LTI system</h3>
<div class="outline-text-3" id="text-1-4">
<p>
Instead of computing the time domain velocity before computing the Power Spectral Density, we could have directly computed the PSD of the measured voltage \(x\) and then take into account the sensitivity of the measurement devices to have the PSD of the velocity.
</p>
<p>
To do so, we use the fact that a signal \(u\) with a PSD \(S_{uu}\) going through a LTI system \(G_(s)\) (figure <a href="#orgb03afbc">6</a>) will generate a signal \(y\) with a PSD:
To do so, we use the fact that a signal \(u\) with a PSD \(S_{uu}\) going through a LTI system \(G_(s)\) (figure <a href="#orgaedfac1">6</a>) will generate a signal \(y\) with a PSD:
</p>
\begin{equation}
S_{yy}(\omega) = \left|G(j\omega)\right|^2 S_{uu}(\omega)
\end{equation}
<div id="orgb03afbc" class="figure">
<div id="orgaedfac1" class="figure">
<p><img src="figs/velocity_to_voltage_psd.png" alt="velocity_to_voltage_psd.png" />
</p>
<p><span class="figure-number">Figure 6: </span>Schematic of the instrumentation used for the measurement</p>
@ -379,11 +369,11 @@ And the PSD of \(v\) is obtained with the below code.
</div>
<p>
The result is compare with the PSD computed from the \(v\) signal obtained with the <code>lsim</code> command in figure <a href="#orge29c9a5">7</a>.
The result is compare with the PSD computed from the \(v\) signal obtained with the <code>lsim</code> command in figure <a href="#orgffdd58a">7</a>.
</p>
<div id="orge29c9a5" class="figure">
<div id="orgffdd58a" class="figure">
<p><img src="figs/psd_velocity_lti_method.png" alt="psd_velocity_lti_method.png" />
</p>
<p><span class="figure-number">Figure 7: </span>Obtain PSD of the velocity using the formula (<a href="./figs/psd_velocity_lti_method.png">png</a>, <a href="./figs/psd_velocity_lti_method.pdf">pdf</a>)</p>
@ -391,15 +381,15 @@ The result is compare with the PSD computed from the \(v\) signal obtained with
</div>
</div>
<div id="outline-container-orgdcf3ecc" class="outline-3">
<h3 id="orgdcf3ecc"><span class="section-number-3">1.5</span> From PSD of the velocity to the PSD of the displacement</h3>
<div id="outline-container-orgdf16414" class="outline-3">
<h3 id="orgdf16414"><span class="section-number-3">1.5</span> From PSD of the velocity to the PSD of the displacement</h3>
<div class="outline-text-3" id="text-1-5">
<p>
Similarly to what has been done in the last section, we can consider the displacement \(d\) can be obtained from the velocity \(v\) by going through an LTI system \(1/s\) as shown in figure <a href="#org36ddbcd">8</a>.
Similarly to what has been done in the last section, we can consider the displacement \(d\) can be obtained from the velocity \(v\) by going through an LTI system \(1/s\) as shown in figure <a href="#orgdc9d2fe">8</a>.
</p>
<div id="org36ddbcd" class="figure">
<div id="orgdc9d2fe" class="figure">
<p><img src="figs/velocity_to_displacement_psd.png" alt="velocity_to_displacement_psd.png" />
</p>
<p><span class="figure-number">Figure 8: </span>Schematic of the instrumentation used for the measurement</p>
@ -443,10 +433,10 @@ With Matlab, the PSD of the displacement can be computed from the PSD of the vel
</div>
<p>
The obtained PSD of the displacement can be seen in figure <a href="#org17622ff">9</a>.
The obtained PSD of the displacement can be seen in figure <a href="#orgbbdf79d">9</a>.
</p>
<div id="org17622ff" class="figure">
<div id="orgbbdf79d" class="figure">
<p><img src="figs/psd_velocity_displacement.png" alt="psd_velocity_displacement.png" />
</p>
<p><span class="figure-number">Figure 9: </span>PSD of the Velocity and Displacement (<a href="./figs/psd_velocity_displacement.png">png</a>, <a href="./figs/psd_velocity_displacement.pdf">pdf</a>)</p>
@ -454,14 +444,14 @@ The obtained PSD of the displacement can be seen in figure <a href="#org17622ff"
</div>
</div>
<div id="outline-container-org4c5249b" class="outline-3">
<h3 id="org4c5249b"><span class="section-number-3">1.6</span> Cumulative Power/Amplitude Spectrum</h3>
<div id="outline-container-orgc31de97" class="outline-3">
<h3 id="orgc31de97"><span class="section-number-3">1.6</span> Cumulative Power/Amplitude Spectrum</h3>
<div class="outline-text-3" id="text-1-6">
<p>
The Cumulative Power Spectrum is the cumulative integral of the Power Spectral Density:
</p>
\begin{equation}
\label{org695c6c9}
\label{orgf27b554}
CPS_v(f) = \int_0^f PSD_v(\nu) d\nu \quad [(m/s)^2]
\end{equation}
@ -469,7 +459,7 @@ The Cumulative Power Spectrum is the cumulative integral of the Power Spectral D
It is also possible to integrate from high frequency to low frequency:
</p>
\begin{equation}
\label{orgb6111fe}
\label{org1c25e5d}
CPS_v(f) = \int_f^\infty PSD_v(\nu) d\nu \quad [(m/s)^2]
\end{equation}
@ -480,7 +470,7 @@ The Cumulative Power Spectrum taken at frequency \(f\) thus represent the power
<p>
The choice of the integral direction depends on the shape of the PSD.
If the power is mostly present at low frequencies, it is preferable to use equation \eqref{orgb6111fe}.
If the power is mostly present at low frequencies, it is preferable to use equation \eqref{org1c25e5d}.
</p>
@ -495,7 +485,7 @@ The Root Mean Square value of the velocity corresponds to the Cumulative Amplitu
</p>
<p>
With Matlab, the Cumulative Power Spectrum can be computed with the below formulas and the results are shown in figure <a href="#org32654d4">10</a>.
With Matlab, the Cumulative Power Spectrum can be computed with the below formulas and the results are shown in figure <a href="#orgd724065">10</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab">CPS_v = cumtrapz(f, Sv); <span class="org-comment">% Cumulative Power Spectrum from low to high frequencies</span>
@ -525,7 +515,7 @@ xlim([0.1, 500]); ylim([1e<span class="org-type">-</span>15, 1e<span class="org-
</div>
<div id="org32654d4" class="figure">
<div id="orgd724065" class="figure">
<p><img src="figs/cps_integral_comp.png" alt="cps_integral_comp.png" />
</p>
<p><span class="figure-number">Figure 10: </span>Cumulative Power Spectrum (<a href="./figs/cps_integral_comp.png">png</a>, <a href="./figs/cps_integral_comp.pdf">pdf</a>)</p>
@ -534,22 +524,16 @@ xlim([0.1, 500]); ylim([1e<span class="org-type">-</span>15, 1e<span class="org-
</div>
</div>
<div id="outline-container-org2810914" class="outline-2">
<h2 id="org2810914"><span class="section-number-2">2</span> Time domain signal that approximate a PSD - TF technique</h2>
<div id="outline-container-org0112edc" class="outline-2">
<h2 id="org0112edc"><span class="section-number-2">2</span> Time domain signal that approximate a PSD - TF technique</h2>
<div class="outline-text-2" id="text-2">
<p>
<a id="org1401958"></a>
<a id="org35aba27"></a>
</p>
<div class="note" id="org89c02ad">
<p>
All the files (data and Matlab scripts) are accessible <a href="data/approximate_psd_tf.zip">here</a>.
</p>
</div>
</div>
<div id="outline-container-org1a03b54" class="outline-3">
<h3 id="org1a03b54"><span class="section-number-3">2.1</span> Signal&rsquo;s PSD</h3>
<div id="outline-container-orgd84f6cb" class="outline-3">
<h3 id="orgd84f6cb"><span class="section-number-3">2.1</span> Signal&rsquo;s PSD</h3>
<div class="outline-text-3" id="text-2-1">
<p>
We load the PSD of the signal we wish to replicate.
@ -572,7 +556,7 @@ dist_f.psd_gm = dist_f.psd_gm(3<span class="org-type">:</span>end);
The PSD of the signal is shown on figure <a href="#fig:psd_ground_motion">fig:psd_ground_motion</a>.
</p>
<div id="org8bb3e89" class="figure">
<div id="org248eaaf" class="figure">
<p><img src="figs/psd_ground_motion.png" alt="psd_ground_motion.png" />
</p>
<p><span class="figure-number">Figure 11: </span>PSD of the signal (<a href="./figs/psd_ground_motion.png">png</a>, <a href="./figs/psd_ground_motion.pdf">pdf</a>)</p>
@ -580,8 +564,8 @@ The PSD of the signal is shown on figure <a href="#fig:psd_ground_motion">fig:ps
</div>
</div>
<div id="outline-container-orgae722c1" class="outline-3">
<h3 id="orgae722c1"><span class="section-number-3">2.2</span> Transfer Function that approximate the ASD</h3>
<div id="outline-container-org347dfb3" class="outline-3">
<h3 id="org347dfb3"><span class="section-number-3">2.2</span> Transfer Function that approximate the ASD</h3>
<div class="outline-text-3" id="text-2-2">
<p>
Using <code>sisotool</code> or any other tool, we create a transfer function \(G\) such that its magnitude is close to the Amplitude Spectral Density \(\Gamma_x = \sqrt{S_x}\):
@ -597,7 +581,7 @@ Using <code>sisotool</code> or any other tool, we create a transfer function \(G
We compare the ASD \(\Gamma_x(\omega)\) and the magnitude of the generated transfer function \(|G(j\omega)|\) in figure [[]].
</p>
<div id="org93e35a8" class="figure">
<div id="org4057d1e" class="figure">
<p><img src="figs/asd_and_tf_compare.png" alt="asd_and_tf_compare.png" />
</p>
<p><span class="figure-number">Figure 12: </span>Comparison of the ASD and of the transfer function&rsquo;s magnitude (<a href="./figs/asd_and_tf_compare.png">png</a>, <a href="./figs/asd_and_tf_compare.pdf">pdf</a>)</p>
@ -605,18 +589,18 @@ We compare the ASD \(\Gamma_x(\omega)\) and the magnitude of the generated trans
</div>
</div>
<div id="outline-container-org0c62275" class="outline-3">
<h3 id="org0c62275"><span class="section-number-3">2.3</span> Generated Time domain signal</h3>
<div id="outline-container-org65665fc" class="outline-3">
<h3 id="org65665fc"><span class="section-number-3">2.3</span> Generated Time domain signal</h3>
<div class="outline-text-3" id="text-2-3">
<p>
We know that a signal \(u\) going through a LTI system \(G\) (figure <a href="#org4ca38ee">13</a>) will have its ASD modified according to the following equation:
We know that a signal \(u\) going through a LTI system \(G\) (figure <a href="#orgf11e462">13</a>) will have its ASD modified according to the following equation:
</p>
\begin{equation}
\Gamma_{yy}(\omega) = \left|G(j\omega)\right| \Gamma_{uu}(\omega)
\end{equation}
<div id="org4ca38ee" class="figure">
<div id="orgf11e462" class="figure">
<p><img src="figs/velocity_to_voltage_psd.png" alt="velocity_to_voltage_psd.png" />
</p>
<p><span class="figure-number">Figure 13: </span>Schematic of the instrumentation used for the measurement</p>
@ -639,7 +623,7 @@ u = sqrt(Fs<span class="org-type">/</span>2)<span class="org-type">*</span>randn
</div>
<p>
We then use <code>lsim</code> to compute \(y\) as shown in figure <a href="#org4ca38ee">13</a>.
We then use <code>lsim</code> to compute \(y\) as shown in figure <a href="#orgf11e462">13</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab">y = lsim(G_gm, u, t);
@ -647,10 +631,10 @@ We then use <code>lsim</code> to compute \(y\) as shown in figure <a href="#org4
</div>
<p>
The obtained time domain signal is shown in figure <a href="#orgf5220b4">14</a>.
The obtained time domain signal is shown in figure <a href="#orgb4fcee7">14</a>.
</p>
<div id="orgf5220b4" class="figure">
<div id="orgb4fcee7" class="figure">
<p><img src="figs/time_domain_u.png" alt="time_domain_u.png" />
</p>
<p><span class="figure-number">Figure 14: </span>Obtained time domain signal \(y(t)\) (<a href="./figs/time_domain_u.png">png</a>, <a href="./figs/time_domain_u.pdf">pdf</a>)</p>
@ -658,8 +642,8 @@ The obtained time domain signal is shown in figure <a href="#orgf5220b4">14</a>.
</div>
</div>
<div id="outline-container-org3713bc7" class="outline-3">
<h3 id="org3713bc7"><span class="section-number-3">2.4</span> Comparison of the Power Spectral Densities</h3>
<div id="outline-container-org2b2326f" class="outline-3">
<h3 id="org2b2326f"><span class="section-number-3">2.4</span> Comparison of the Power Spectral Densities</h3>
<div class="outline-text-3" id="text-2-4">
<p>
We now compute the Power Spectral Density of the computed time domain signal \(y\).
@ -677,7 +661,7 @@ win = hanning(floor(nx<span class="org-type">/</span>na));
Finally, we compare the PSD of the original signal and the obtained signal on figure <a href="#fig:psd_comparison">fig:psd_comparison</a>.
</p>
<div id="org433994e" class="figure">
<div id="org051f89d" class="figure">
<p><img src="figs/compare_psd_tf_technique.png" alt="compare_psd_tf_technique.png" />
</p>
<p><span class="figure-number">Figure 15: </span>Comparison of the original PSD and the PSD of the computed time domain signal (<a href="./figs/compare_psd_tf_technique.png">png</a>, <a href="./figs/compare_psd_tf_technique.pdf">pdf</a>)</p>
@ -685,15 +669,15 @@ Finally, we compare the PSD of the original signal and the obtained signal on fi
</div>
</div>
<div id="outline-container-org35debdf" class="outline-3">
<h3 id="org35debdf"><span class="section-number-3">2.5</span> Simulink</h3>
<div id="outline-container-orgbce7f0e" class="outline-3">
<h3 id="orgbce7f0e"><span class="section-number-3">2.5</span> Simulink</h3>
<div class="outline-text-3" id="text-2-5">
<p>
One advantage of this technique is that it can be easily integrated into simulink.
</p>
<p>
The corresponding schematic is shown in figure <a href="#org7960bdb">16</a> where the block <code>Band-Limited White Noise</code> is used to generate a random signal with a PSD equal to one (parameter <code>Noise Power</code> is set to 1).
The corresponding schematic is shown in figure <a href="#orgf576db1">16</a> where the block <code>Band-Limited White Noise</code> is used to generate a random signal with a PSD equal to one (parameter <code>Noise Power</code> is set to 1).
</p>
<p>
@ -701,14 +685,14 @@ Then, the signal generated pass through the transfer function representing the w
</p>
<div id="org7960bdb" class="figure">
<div id="orgf576db1" class="figure">
<p><img src="figs/simulink_psd_generate.png" alt="simulink_psd_generate.png" />
</p>
<p><span class="figure-number">Figure 16: </span>Simulink Schematic</p>
</div>
<p>
We simulate the system shown in figure <a href="#org7960bdb">16</a>.
We simulate the system shown in figure <a href="#orgf576db1">16</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab">out = <span class="org-matlab-simulink-keyword">sim</span>(<span class="org-string">'matlab/generate_signal_psd.slx'</span>);
@ -728,10 +712,10 @@ win = hanning(floor(nx<span class="org-type">/</span>na));
</div>
<p>
Finally, we compare the PSD of the generated signal with the original PSD in figure <a href="#orga173ec7">17</a>.
Finally, we compare the PSD of the generated signal with the original PSD in figure <a href="#orgb0970f8">17</a>.
</p>
<div id="orga173ec7" class="figure">
<div id="orgb0970f8" class="figure">
<p><img src="figs/compare_psd_original_simulink.png" alt="compare_psd_original_simulink.png" />
</p>
<p><span class="figure-number">Figure 17: </span>Comparison of the obtained signal&rsquo;s PSD and original PSD (<a href="./figs/compare_psd_original_simulink.png">png</a>, <a href="./figs/compare_psd_original_simulink.pdf">pdf</a>)</p>
@ -740,18 +724,12 @@ Finally, we compare the PSD of the generated signal with the original PSD in fig
</div>
</div>
<div id="outline-container-org00702f7" class="outline-2">
<h2 id="org00702f7"><span class="section-number-2">3</span> Time domain signal that approximate a PSD - IFFT technique</h2>
<div id="outline-container-org56d1b86" class="outline-2">
<h2 id="org56d1b86"><span class="section-number-2">3</span> Time domain signal that approximate a PSD - IFFT technique</h2>
<div class="outline-text-2" id="text-3">
<p>
<a id="org8fad482"></a>
<a id="orgb97846a"></a>
</p>
<div class="note" id="orgce82865">
<p>
All the files (data and Matlab scripts) are accessible <a href="data/approximate_psd_ifft.zip">here</a>.
</p>
</div>
<p>
The technique comes from (<a href="#citeproc_bib_item_1">Preumont 1994</a>) (section 12.11).
It is used to compute a periodic signal that has any Power Spectral Density defined.
@ -759,8 +737,8 @@ It makes used of the Unversed Fast Fourier Transform (IFFT).
</p>
</div>
<div id="outline-container-org1700082" class="outline-3">
<h3 id="org1700082"><span class="section-number-3">3.1</span> Signal&rsquo;s PSD</h3>
<div id="outline-container-org5fd81fb" class="outline-3">
<h3 id="org5fd81fb"><span class="section-number-3">3.1</span> Signal&rsquo;s PSD</h3>
<div class="outline-text-3" id="text-3-1">
<p>
We load the PSD of the signal we wish to replicate.
@ -783,7 +761,7 @@ dist_f.psd_gm = dist_f.psd_gm(3<span class="org-type">:</span>end);
The PSD of the signal is shown on figure <a href="#fig:psd_original">fig:psd_original</a>.
</p>
<div id="orga9af359" class="figure">
<div id="org7675839" class="figure">
<p><img src="figs/psd_original.png" alt="psd_original.png" />
</p>
<p><span class="figure-number">Figure 18: </span>PSD of the original signal (<a href="./figs/psd_original.png">png</a>, <a href="./figs/psd_original.pdf">pdf</a>)</p>
@ -791,8 +769,8 @@ The PSD of the signal is shown on figure <a href="#fig:psd_original">fig:psd_ori
</div>
</div>
<div id="outline-container-org4ce31b2" class="outline-3">
<h3 id="org4ce31b2"><span class="section-number-3">3.2</span> Algorithm</h3>
<div id="outline-container-org04e5156" class="outline-3">
<h3 id="org04e5156"><span class="section-number-3">3.2</span> Algorithm</h3>
<div class="outline-text-3" id="text-3-2">
<p>
We define some parameters that will be used in the algorithm.
@ -838,8 +816,8 @@ Cx = [Cx; flipud(conj(Cx(2<span class="org-type">:</span>end)))];;
</div>
</div>
<div id="outline-container-orga9ef28c" class="outline-3">
<h3 id="orga9ef28c"><span class="section-number-3">3.3</span> Obtained Time Domain Signal</h3>
<div id="outline-container-org090de25" class="outline-3">
<h3 id="org090de25"><span class="section-number-3">3.3</span> Obtained Time Domain Signal</h3>
<div class="outline-text-3" id="text-3-3">
<p>
The time domain data is generated by an inverse FFT.
@ -855,7 +833,7 @@ t = linspace(0, T0, N<span class="org-type">+</span>1); <span class="org-comment
</div>
<div id="org409aee0" class="figure">
<div id="org5a0bee0" class="figure">
<p><img src="figs/signal_time_domain.png" alt="signal_time_domain.png" />
</p>
<p><span class="figure-number">Figure 19: </span>Obtained signal in the time domain (<a href="./figs/signal_time_domain.png">png</a>, <a href="./figs/signal_time_domain.pdf">pdf</a>)</p>
@ -863,8 +841,8 @@ t = linspace(0, T0, N<span class="org-type">+</span>1); <span class="org-comment
</div>
</div>
<div id="outline-container-org92e1c44" class="outline-3">
<h3 id="org92e1c44"><span class="section-number-3">3.4</span> PSD Comparison</h3>
<div id="outline-container-org8798466" class="outline-3">
<h3 id="org8798466"><span class="section-number-3">3.4</span> PSD Comparison</h3>
<div class="outline-text-3" id="text-3-4">
<p>
We duplicate the time domain signal to have a longer signal and thus a more precise PSD result.
@ -890,7 +868,7 @@ win = hanning(floor(nx<span class="org-type">/</span>na));
Finally, we compare the PSD of the original signal and the obtained signal on figure <a href="#fig:psd_comparison">fig:psd_comparison</a>.
</p>
<div id="orgf3ef538" class="figure">
<div id="orgf027902" class="figure">
<p><img src="figs/psd_comparison.png" alt="psd_comparison.png" />
</p>
<p><span class="figure-number">Figure 20: </span>Comparison of the PSD of the original signal and the PSD of the obtained signal (<a href="./figs/psd_comparison.png">png</a>, <a href="./figs/psd_comparison.pdf">pdf</a>)</p>
@ -899,26 +877,20 @@ Finally, we compare the PSD of the original signal and the obtained signal on fi
</div>
</div>
<div id="outline-container-orgce7f3a9" class="outline-2">
<h2 id="orgce7f3a9"><span class="section-number-2">4</span> Compute the Noise level and Signal level from PSD</h2>
<div id="outline-container-org11ee648" class="outline-2">
<h2 id="org11ee648"><span class="section-number-2">4</span> Compute the Noise level and Signal level from PSD</h2>
<div class="outline-text-2" id="text-4">
<p>
<a id="orgb30a0a4"></a>
<a id="orgcd3ff15"></a>
</p>
<div class="note" id="org44b6f9e">
<p>
All the files (data and Matlab scripts) are accessible <a href="data/compute_psd_levels.zip">here</a>.
</p>
</div>
<p>
We here make use of the Power Spectral Density to estimate either the noise level or the amplitude of a deterministic signal.
Everything is explained in (<a href="#citeproc_bib_item_2">Schmid 2012</a>) sections 5 and 6.
</p>
</div>
<div id="outline-container-org57f2f45" class="outline-3">
<h3 id="org57f2f45"><span class="section-number-3">4.1</span> Time Domain Signal</h3>
<div id="outline-container-orgf5f2a97" class="outline-3">
<h3 id="orgf5f2a97"><span class="section-number-3">4.1</span> Time Domain Signal</h3>
<div class="outline-text-3" id="text-4-1">
<p>
Let&rsquo;s first define the number of sample and the sampling time.
@ -954,7 +926,7 @@ anoi = 1e<span class="org-type">-</span>3; <span class="org-comment">% RMS value
</div>
<p>
The signal \(x\) is generated with the following code and is shown in figure <a href="#orgab8932d">21</a>.
The signal \(x\) is generated with the following code and is shown in figure <a href="#org08eb44d">21</a>.
</p>
<div class="org-src-container">
<pre class="src src-matlab">x = anoi<span class="org-type">*</span>randn(N, 1) <span class="org-type">+</span> asig<span class="org-type">*</span>sin((2<span class="org-type">*</span><span class="org-constant">pi</span><span class="org-type">*</span>fsig)<span class="org-type">*</span>t) <span class="org-type">+</span> ahar<span class="org-type">*</span>sin((2<span class="org-type">*</span><span class="org-constant">pi</span><span class="org-type">*</span>fhar)<span class="org-type">*</span>t);
@ -962,7 +934,7 @@ The signal \(x\) is generated with the following code and is shown in figure <a
</div>
<div id="orgab8932d" class="figure">
<div id="org08eb44d" class="figure">
<p><img src="figs/time_domain_x_zoom.png" alt="time_domain_x_zoom.png" />
</p>
<p><span class="figure-number">Figure 21: </span>Time Domain Signal (<a href="./figs/time_domain_x_zoom.png">png</a>, <a href="./figs/time_domain_x_zoom.pdf">pdf</a>)</p>
@ -970,8 +942,8 @@ The signal \(x\) is generated with the following code and is shown in figure <a
</div>
</div>
<div id="outline-container-org3f32ef0" class="outline-3">
<h3 id="org3f32ef0"><span class="section-number-3">4.2</span> Estimation of the magnitude of a deterministic signal</h3>
<div id="outline-container-org54820b0" class="outline-3">
<h3 id="org54820b0"><span class="section-number-3">4.2</span> Estimation of the magnitude of a deterministic signal</h3>
<div class="outline-text-3" id="text-4-2">
<p>
Let&rsquo;s compute the PSD of the signal using the <code>blackmanharris</code> window.
@ -1063,8 +1035,8 @@ Thus, always the integrated method should be used.
</div>
</div>
<div id="outline-container-org5ab6d13" class="outline-3">
<h3 id="org5ab6d13"><span class="section-number-3">4.3</span> Estimation of the noise level</h3>
<div id="outline-container-orgb8e3ada" class="outline-3">
<h3 id="orgb8e3ada"><span class="section-number-3">4.3</span> Estimation of the noise level</h3>
<div class="outline-text-3" id="text-4-3">
<p>
The noise level can also be computed using the integration method.
@ -1120,12 +1092,12 @@ The estimate of the noise level is quite good.
</div>
</div>
<div id="outline-container-orgda903f8" class="outline-2">
<h2 id="orgda903f8"><span class="section-number-2">5</span> Further Notes</h2>
<div id="outline-container-org2405c66" class="outline-2">
<h2 id="org2405c66"><span class="section-number-2">5</span> Further Notes</h2>
<div class="outline-text-2" id="text-5">
</div>
<div id="outline-container-orge7125fc" class="outline-3">
<h3 id="orge7125fc"><span class="section-number-3">5.1</span> PSD of ADC quantization noise</h3>
<div id="outline-container-org6ea3373" class="outline-3">
<h3 id="org6ea3373"><span class="section-number-3">5.1</span> PSD of ADC quantization noise</h3>
<div class="outline-text-3" id="text-5-1">
<p>
This is taken from <a href="https://www.allaboutcircuits.com/technical-articles/quantization-nois-amplitude-quantization-error-analog-to-digital-converters/">here</a>.
@ -1149,11 +1121,11 @@ Interestingly, the noise amplitude is uniformly distributed.
<p>
The quantization noise can take a value between \(\pm q/2\), and the probability density function is constant in this range (i.e., its a uniform distribution).
Since the integral of the probability density function is equal to one, its value will be \(1/q\) for \(-q/2 < e < q/2\) (Fig. <a href="#orge1a8015">22</a>).
Since the integral of the probability density function is equal to one, its value will be \(1/q\) for \(-q/2 < e < q/2\) (Fig. <a href="#org4009b25">22</a>).
</p>
<div id="orge1a8015" class="figure">
<div id="org4009b25" class="figure">
<p><img src="figs/probability_density_function_adc.png" alt="probability_density_function_adc.png" />
</p>
<p><span class="figure-number">Figure 22: </span>Probability density function \(p(e)\) of the ADC error \(e\)</p>
@ -1211,7 +1183,7 @@ Finally:
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2020-11-11 mer. 13:53</p>
<p class="date">Created: 2020-11-12 jeu. 10:22</p>
</div>
</body>
</html>