Cross-Spectrum: Concept and Mathematics
The cross-spectrum measures the frequency-domain correlation between two signals, showing how the signals relate in magnitude and phase at each frequency.
For two discrete-time signals x[n] and y[n], the cross-spectral density is defined as:
Sxy(f) = X(f) · Y*(f)
X(f) = FFT{x[n]}→ Fourier transform of x[n]Y(f) = FFT{y[n]}→ Fourier transform of y[n]Y*(f)→ Complex conjugate of Y(f)|Sxy(f)|→ Magnitude shows correlation strength at each frequency∠Sxy(f)→ Phase shows relative phase difference
Cross-spectrum is widely used in:
- Beamforming
- Coherence analysis
- Direction-of-arrival estimation (DoA)
- Identifying frequency-dependent relationships between signals
MATLAB Code Example
This MATLAB example demonstrates the cross-spectrum between two sinusoidal signals with a phase difference:
%% Cross-Spectrum Demonstration
clc; clear; close all;
%% PARAMETERS
Fs = 1000; % Sampling frequency [Hz]
T = 1/Fs;
t = 0:T:1-T; % 1 second duration
f_sig = 50; % Signal frequency [Hz]
%% SIMULATE TWO SIGNALS
x = sin(2*pi*f_sig*t); % Reference signal
y = 0.8*sin(2*pi*f_sig*t + pi/4); % Signal with 45° phase shift
%% COMPUTE CROSS-SPECTRUM
X = fft(x);
Y = fft(y);
S_xy = X .* conj(Y); % Cross-spectrum
%% FREQUENCY VECTOR
N = length(t);
f = Fs*(0:N-1)/N;
%% PLOT
figure('Color','w');
% Magnitude of cross-spectrum
subplot(2,1,1)
plot(f(1:N/2), abs(S_xy(1:N/2))/N, 'LineWidth',1.5)
grid on
xlabel('Frequency [Hz]')
ylabel('|S_{xy}(f)|')
title('Cross-Spectrum Magnitude')
% Phase of cross-spectrum
subplot(2,1,2)
plot(f(1:N/2), angle(S_xy(1:N/2))*180/pi, 'LineWidth',1.5)
grid on
xlabel('Frequency [Hz]')
ylabel('Phase [deg]')
title('Cross-Spectrum Phase')
Explanation:
S_xy = X .* conj(Y)computes the cross-spectrum.- The magnitude plot shows which frequencies are strongly correlated.
- The phase plot shows the phase difference at each frequency.
- This is a simple demonstration for understanding frequency-domain correlation.