0
$\begingroup$

I have a spectra of power spectral density (PSD) (vector (1:1e6)) from experimental data (blue color).

enter image description here

However I want to plot only average value of PSD (red curve).

How can I do it by using MATLAB?

Thank you so much !

$\endgroup$
  • $\begingroup$ Just my usual ranting: the PSD is a stochastic expectation value. What you have, based on an experiment, is an estimate of the PSD. $\endgroup$ – Marcus Müller Mar 23 '17 at 8:13
0
$\begingroup$

You should remove how frequency content of the diagram. Simply use moving average filter. find the optimum filter size that produces your desired result. Here is a matlab example code.

t=0:0.001:1;
PSD=2*sin(2*pi*1*t)+10*randn(size(t))+5; %assume as the power spectrum
filtered=zeros(size(t));
M=20 ;% Moving average filter size
for i=1:length(t)-M
    filtered(i)=mean(PSD(i:i+M));
end
plot(PSD);
hold on
plot(filtered,'r')

enter image description here

$\endgroup$
  • $\begingroup$ Actually, I need to plot the frequency dispersion of frequency noise from laser. That why I have to use the frequency in this graph. $\endgroup$ – Hiep Xuan Dinh Mar 23 '17 at 7:18
  • $\begingroup$ Actually, by frequency, I do not mean the frequency of actual data (which in your case is noise from laser). I meant to consider the PSD plot itself as a signal. $\endgroup$ – MimSaad Mar 23 '17 at 8:52

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.