MATLAB: Is the unit of Cxy from cpsd in decibel

cpsdcxydecibelgainphasesignal processingSignal Processing Toolbox

Hi,
I want to use the Signal Processing Toolbox to compute the Cross spectrum gain and phase for my sequences X and Y. I wondered the Cxy that cpsd gives me is in the units of dB? I saw the example and it says the unit is dB/rad/freq, how can I convert it to dB?
Thank you so much!

Best Answer

Hi, no, the output is the cross spectrum, it is complex-valued. If you want the output in db. Use
10*log10(abs(Pxy));
For example:
Fs = 1000;
t = 0:1/Fs:.296;
x = cos(2*pi*t*200)+randn(size(t));
y = cos(2*pi*t*100)+randn(size(t));
[Pxy,F] = cpsd(x,y,[],[],[],Fs);
plot(F,10*log10(abs(Pxy))); grid on;
% compare to
figure;
cpsd(x,y,[],[],[],Fs);