Member of the spectral analysis class.
csd(x, y)
csd(x, y, nfft, fs, window)
csd(x, y, nfft, fs, window, noverlap)
csd(x, y, nfft, fs, window, noverlap, flag)
Sxy = csd(x, y)
Sxy = csd(x, y, nfft, fs, window)
Sxy = csd(x, y, nfft, fs, window, noverlap)
Sxy = csd(x, y, nfft, fs, window, noverlap, flag)
[Sxy, f] = csd(x, y)
[Sxy, f] = csd(x, y, nfft, fs, window)
[Sxy, f] = csd(x, y, nfft, fs, window, noverlap)
[Sxy, f] = csd(x, y, nfft, fs, window, noverlap, flag)
Uses the Welch method to estimate the cross-spectrum density. If you do not specify an output, this function plots the magnitude of the cross power spectrum in the current plot window.
| Name | Description | ||||||
| x | Specifies the first input sequence. | ||||||
| y | Specifies the second input sequence. length(y) must equal length(x). | ||||||
| nfft | Specifies the length of the FFT to perform on each segment of data. The default is the minimum of 256 and the length of x. | ||||||
| fs | Specifies the sampling frequency. The default is 2. | ||||||
| window | Specifies the window to apply to x and y. The length of window must be less than or equal to nfft. The default is a Hanning window with a length of nfft. | ||||||
| noverlap | Specifies the number of overlapping data elements between adjacent segments of data. noverlap must be less than the length of window. The default is 0. | ||||||
| flag | Specifies the method to use to preprocess x and y before applying the window. flag is a string that accepts the following values.
|
| Name | Description |
| Sxy | Returns the cross power spectrum of the input signals x and y. If x and y are real, the length of Sxy is nfft / 2 + 1 for an even nfft and (nfft + 1) / 2 for an odd nfft. If x and y are complex, the length of Sxy is nfft. |
| f | Returns the frequencies that correspond to Sxy. |
This function is supported in the LabVIEW Run-Time Engine only if you request an output from the function. This function can remain in your scripts when you build a stand-alone application or shared library, but if you do not request an output, the LabVIEW Run-Time Engine does not execute this function. If you request an output, the LabVIEW Run-Time Engine executes this function as normal.
fs = 1000;
f = 100;
T = 2;
t = 0:1 / fs:T - 1/fs;
x = sin(2*pi*f*t) + 10*t;
y = sin(2*pi*0.5*f*t) + 20*t;
nfft = 256;
[pxy fxy] = csd(x, y, nfft, fs, hanning(nfft), nfft / 2, 'linear');