title: How to measure power spectral density in matlab?
body: <p>I am trying to measure the PSD of a stochastic process in matlab, but I am not sure how to do it. I have posted the exact same question <a href="https://math.stackexchange.com/q/468290/30734">here</a>, but I thought I might have more luck here.</p>
  
  <p>The stochastic process describes wind speed, and is represented by a vector of real numbers. Each entry corresponds to the wind speed in a point in space, measured in m/s. The points are 0.0005 m apart. How do I measure and plot the PSD? Let's call the vector <code>V</code>. My first idea was to use</p>
  
  <pre><code>[p, w] = pwelch(V);
  loglog(w,p);
  </code></pre>
  
  <p>But is this correct? The thing is, that I'm given an analytical expression, which the PSD should (in theory) match. By plotting it with these two lines of code, it looks all wrong. Specifically it looks as though it could need a translation and a scaling. Other than that, the shapes of the two are similar.</p>
  
  <p><img src="https://i.stack.imgur.com/m74Dh.jpg" alt="enter image description here"></p>
  
  <p><strong>UPDATE:</strong>
  The image above actually doesn't depict the PSD obtained by using <code>pwelch</code> on a single vector, but rather the mean of the PSD of 200 vectors, since these vectors stems from numerical simulations. As suggested, I have tried scaling by 2*pi/0.0005. I saw that you can actually give this information to <code>pwelch</code>. So I tried using the code</p>
  
  <pre><code>[p, w] = pwelch(V,[],[],[],2*pi/0.0005);
  loglog(w,p);
  </code></pre>
  
  <p>instead. As seen below, it looks much nicer. It is, however, still not perfect. Is that just something I should expect? Taking the squareroot is not the answer, by the way. But thanks for the suggestion. For one thing, it should follow Kolmogorov's -5/3 law, which it does now (it follows the green line, which has slope -5/3). The function I'm trying to match it with is the Shkarofsky spectral density function, which is the one-dimensional Fourier transform of the Shkarofsky correlation function. Is it not possible to mark up math, here on the site?</p>
  
  <p><img src="https://i.stack.imgur.com/u8MJB.jpg" alt="enter image description here"></p>
  
  <p><strong>UPDATE 2:</strong>
  I have tried using <code>[p, w] = pwelch(V,[],[],[],1/0.0005);</code> as I was suggested. But as you can seem it still doesn't quite match up. It's hard for me to explain exactly what I'm looking for. But what I would like (or, what I expected) is that the dip, of the computed and the analytical PSD happens at the same time, and falls off with the same speed. The data comes from simulations of turbulence. The analytical expression has been fitted to actual measurements of turbulence, wherein this dip is present as well. I'm no expert at all, but as far as I know the dip happens at the small length scales, since the energy is dissipated, due to viscosity of the air.</p>
  
  <p><img src="https://i.stack.imgur.com/55cmm.jpg" alt="enter image description here"></p>