cpsd output vector differs from plotted result
When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks!When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks! When using cpsd to calculate the cross power spectral density, I’ve noticed that the plot produced by directly running the command with no output arguments is slightly different from what I get when I run it with an output argument and plot that output myself.
The following code (attached along with example signal file) produces the figure below.
signalx = randn(2e4,1);
signaly = randn(2e4,1);
window = length(signalx)/3;
noverlap = round(0.9*window);
fs = 2074;
[Pxy,F] = cpsd(signalx,signaly,window,noverlap,[],fs);
plot(F./1000,10.*log10(real(Pxy)))
hold on
cpsd(signalx,signaly,window,noverlap,[],fs);
legend(‘CPSD output’,’CPSD direct plot’)
I’m trying to run cpsd column-wise on a pair of very large matrices. Obviously I can’t just plot them one by one, but I don’t know how to interpret this difference and I’m not sure if I trust the output argument. Does anyone know what’s going on here? Thanks! signal processing, cross power spectral density, cpsd, spectral analysis MATLAB Answers — New Questions