# Power spectral density of the output response of a linear state space model

**URL:** <https://community.wolfram.com/t/power-spectral-density-of-the-output-response-of-a-linear-state-space-model/9914>\
**Category:** Questions\
**Tags:** control-systems, graphics-and-visualization, modeling\
**Created:** [January 20, 2017, 4:43pm UTC](https://community.wolfram.com/t/power-spectral-density-of-the-output-response-of-a-linear-state-space-model/9914 "2017-01-20T16:43:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![miraveta](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@miraveta](https://community.wolfram.com/u/miraveta)\
**Post date:** [January 20, 2017, 4:43pm UTC](https://community.wolfram.com/t/power-spectral-density-of-the-output-response-of-a-linear-state-space-model/9914/1 "2017-01-20T16:43:25Z")

</div>

I have the following Linear State Space Model. It is pasted in Normal form for it to be readable.

```
provalin={{{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {-355743., -2708.82, 
   4.38556*10^6, -23134.7, 3.24779*10^7, 252220., 1.9571*10^8, 
   1.54331*10^6, 1.3344*10^9, 1.04062*10^7, 195127., -60114.7}, {0, 0,
    0, 1, 0, 0, 0, 0, 0, 0, 0, 
   0}, {-1740.54, -2.07579, -37052.7, -188.127, 124023., 961.386, 
   2.47582*10^6, 19977.9, 1.53934*10^7, 
   121345., -5620.58, -784.516}, {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
   0}, {206.237, 0.144667, 0, 0, -20690.5, -378.64, 0, 0, 0, 0, 0, 
   0}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 291.405, 0.45, 0, 
   0, -18814.8, -359.96, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
   0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, -20110., -372.677, 0, -1.}, {0, 0, 
   0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {100.113, 0.0743233, 3035.71, 
   7.23123, 16113., 124.954, 272165., 2192.23, 1.70504*10^6, 
   13428.4, -547.949, -86.0336}}, {{0}, {449.745}, {0}, {-0.412829}, \
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0.00736309}}, {{0, 0, 0, 0, 0, 0, 
   0, 0, 0, 0, 1, 0}}, {{0}}};

```

I’ve tried to construct the PSD with the following code.

```
slv = OutputResponse[
   StateSpaceModel[provalin], {0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {t, 0, 200}];
listat = Flatten[Table[slv /. t -> tt, {tt, 0, 200, 0.1}]];
Periodogram[listat, ScalingFunctions -> "Absolute"]

```

I’ve obtained this way the following plot:

 ![linearPSD.png](https://global.discourse-cdn.com/wolfram/original/3X/0/b/0b32f5f891be4d601a59c65efd95ad6aadc6814b.png)

Though I expected to have only peaks without that initial slope. How is it? Am I wrongly setting the PSD? What are the right strategies to get this done cleanly?

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [January 20, 2017, 9:37pm UTC](https://community.wolfram.com/t/power-spectral-density-of-the-output-response-of-a-linear-state-space-model/9914/2 "2017-01-20T21:37:51Z")

</div>

Mirko,

Your problem is that the response has large DC components.

If you plot your data:

```
ListLinePlot[listat]

```

you get:

 ![ScreenShot2017-01-20at4.27.01PM.png](https://global.discourse-cdn.com/wolfram/original/3X/e/5/e5618c87d246bf52273e22899add36068d6ecbd2.png)

Note that you have a large step followed by a decaying sinusoid.

If you take off the initial step you will get a PSD that has a Spike at 0.

```
nlistat = listat[[13 ;;]];
ListLinePlot[nlistat]

```

to get:

 ![ScreenShot2017-01-20at4.27.23PM.png](https://global.discourse-cdn.com/wolfram/original/3X/9/7/97642a563fcdff69869f216f77c323882fc8acef.png)

If you then subtract off the mean, you will get the PSD that you were expecting.

```
nnlistat = nlistat - Mean[nlistat];

```

The data is:

 ![ScreenShot2017-01-20at4.27.39PM.png](https://global.discourse-cdn.com/wolfram/original/3X/3/1/312d1b647930891de778447efaca6d79d0a8517a.png)

and the PSD for the last two examples are (top is data with no step but a mean offset (spike at zero)). Bottom plot is final version.

 ![ScreenShot2017-01-20at4.28.01PM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/8/682440ccea1821004d1b018647ab8c47a3dac618.png)

or zoomed out:

 ![ScreenShot2017-01-20at4.34.31PM.png](https://global.discourse-cdn.com/wolfram/original/2X/a/a428dc086c7e1ab5a6f5222d4fab4f100c2cdd15.png)

Regards,

Neil
