next up previous contents
Next: Power Spectrum of an Up: Power Spectrum Previous: Power Spectrum of a   Contents

Power Spectrum of a noised sinusoid

Now we are going to mask our signal with noise

-->rand('normal')
 
-->rand('seed',0)
  
-->xnoised  = x + 2*rand(x);
We can represent both signals (original and noised) at the same scale with the next code


-->xsetech([0,0,1,1/2],[0,-10,1,10]);
 
-->plot2d([0:99]*inct, x(1:100),1,'001');
 
-->xsetech([0,1/2,1,1/2],[0,-10,1,10]);
 
-->plot2d([0:99]*inct, xnoised(1:100),1,'001');
Notice that we represent the first 100 values (one second)
Figure 12.1: Original signal (upper frame) and signal masked with Gaussian noise (lower trace)
\begin{figure}
\epsfbox{figures/power1.eps}
\end{figure}
Now we are going to calculate the Fourier Transform of three periods of 100 values


-->x1 = xnoised(1:100);
 
-->ffx1 = fft(x1,-1);
 
 
-->x2 = xnoised(101:200);
 
-->ffx2 = fft(x2,-1);
 
 
-->x3 = xnoised(201:300);
 
-->ffx3 = fft(x3,-1);
At this moment we have three different arrays and we could average them. The result is shown in the upper trace of the next figure but we have a command that calculates the average of the power of several windows on the signal


-->Pxx = pspect(50,100,'re',xnoised);
With this command, we are saying that `xnoise' was divided in windows of 100 values and that the power spectrum be calculated. Finally the different spectra are averaged. We can apply different windows (rectangular, hamming...).

Notice that we can overlap the different windows by using the first parameter. The result can be seen with the next code


-->xbasc()
 
-->xsetech([0,0,1,1/2])
 
 
-->fr = [0:99]*(1/ (100*inct));
 
 
-->plot2d(fr,(abs(ffx1)^2 /100),1);
 
-->plot2d(fr,(abs(ffx2)^2 /100),1,'001');
 
-->plot2d(fr,(abs(ffx3)^2 /100),1,'001');
 
 
-->xsetech([0,1/2,1,1/2])

-->plot2d(fr,Pxx)
The result can be seen in the next figure

Figure 12.2: Superimposition of the Fourier Transform of three different segments and Power Spectrum calculated with `pspect'
\begin{figure}
\epsfbox{figures/power2.eps}
\end{figure}
Notice that the result calculated with `pspect' has not been divided by the number of samples because it is implemented in the code of the function.


next up previous contents
Next: Power Spectrum of an Up: Power Spectrum Previous: Power Spectrum of a   Contents
j 2003-01-23