Effect of fft-length within cpsd

Hi, I want to calculate the cross-power-spectral-density of two stochastic signals using cpsd. Using a simple example, I noticed that the fft-length influences the results. Where does this behaviour come from? And how to get rid of it? I mean the power-spectral-density must not be affected by the fft-length. Sure, there must be less points with a shorter fft-length, but the mean-value should remain constant irrespective of the fft-length. Or am I misunderstanding something?
if true
fs=10000; % sampling frequency
sigA=rand(1,1000000); % signal A
sigB=rand(1,1000000); % signal B
nfft1=2^10; % fft-length 1
win1=hann(nfft1); % window 1
overlap1=nfft1/2; % overlap 1
nfft2=2^14; % fft-length 2
win2=hann(nfft2); % window 2
overlap2=nfft2/2; % overlap 2
[Pxy1,F1]=cpsd(sigA,sigB,win1,overlap1,nfft1,fs); % cpsd calculation 1
[Pxy2,F2]=cpsd(sigA,sigB,win2,overlap2,nfft2,fs); % cpsd calculation 2
Pxy1=10*log10(abs(Pxy1));
Pxy2=10*log10(abs(Pxy2));
figure % one figure with both results
semilogx(F1,Pxy1)
hold on
semilogx(F2,Pxy2,'r:')
grid on
legend('nfft=2^{10}','nfft=2^{14}')
axis([100 5e3 -80 -50])
figure % plot 2 figures directly from cpsd function
cpsd(sigA,sigB,win1,overlap1,nfft1,fs)
figure
cpsd(sigA,sigB,win2,overlap2,nfft2,fs)
end

1 Comment

I think this is unique to the cross spectra, but I don't have a complete explanation. At a basic level, with 10^10, there are a lot more cross spectra results being averaged, these are two incoherent signals and so the more we average, the closer to zero the cross spectra will go. If you increase your record length it also has the affect of driving down the cross spectra; this makes sense to me, and you would not see this looking a the auto-spectra for either channel.

Sign in to comment.

Answers (0)

Asked:

on 15 Jul 2015

Commented:

on 21 Jul 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!