I have profiled a surface, measuring the height of peaks and troughs at 0.02mm intervals. I have 1501 data points, the below listed as an example:

$$\begin{align} x &= 0\,\mu\text m & y &= 20\,\mu\text m\\ x &= 20\,\mu\text m & y &= 15\,\mu\text m\\ x &= 40\,\mu\text m & y &= 12\,\mu\text m\\ x &= 60\,\mu\text m & y &= 10\,\mu\text m\\ \end{align}$$

How do I generate a spatial as opposed to frequency PSD plot using Matlab? i.e. what function should I use.


  • $\begingroup$ Just think of your $x$ being called $t$. It doesn't matter for the underlying math what your units of physical significance of the data is. $\endgroup$ May 27 '16 at 12:20
  • $\begingroup$ If you actually consider this, you couldn't call it Power Spectral Density, because Power is "Energy per Time", and you have neither Energy nor time as axes (you can argue potential energy is proportional to height square just as electrical signal energy is proportional to voltage square, though). I'd probably call this a "Potential spectral density"; you could even keep the PSD acronym :) $\endgroup$ May 27 '16 at 12:21
  • $\begingroup$ Correction: "Potential" neglects the "Energy per length" aspect, so I'd probably call this a "Slope spectral density"; "Slope" is "height over length"; SPD is a nice name. $\endgroup$ May 27 '16 at 12:27
  • $\begingroup$ I went ahead and made both columns of data have the same unit, μm. $\endgroup$ May 27 '16 at 12:30
  • 1
    $\begingroup$ by the way, have you really only got these four points? $\endgroup$ May 27 '16 at 12:30

A spectrum estimation method that works well in many cases is Welch's method. The MATLAB implementation is pretty straight forward to use, even when not knowing about the math behind it. Following Marcus' recommendations, you could try:

if norm(diff(X,2)) < sqrt(eps) % is X evenly spaced ?
    Fs = 1/mean(diff(X)); % find the step size of X
    [Pyy,F] = pwelch(Y,[],[],[],Fs,'onesided','PSD'); % compute the PSD
    plot(log10(F),log10(Pyy)), xlabel('log [\mum^{-1}]'), ylabel('log[PSD[\mum^2/\mum^{-1}]]')
    axis tight, grid on
  • $\begingroup$ Thanks for this, it appears to be giving me sensible looking results, certainly correlates with what I can physically see in the raw data. $\endgroup$
    – Pop24
    May 31 '16 at 16:25
  • $\begingroup$ Good :) there was a mistake in the code example, by the way, Fs should be the inverse of the step size... I've made an edit $\endgroup$
    – Arnfinn
    May 31 '16 at 23:40
  • $\begingroup$ Thank you very much for the explanation, code in this thread. How can we calculate the slope of the PSD curve? $\endgroup$ Jun 10 '20 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.