svd实现music算法
% Parameters
M = 8; % Number of array elements
N = 1000; % Number of snapshots
d = 0.5; % Distance between elements (in wavelengths)
theta_s = [30, 60]; % Signal directions (in degrees)
SNR = 20; % Signal-to-noise ratio (dB)
% Generate the steering matrix
A = [];
for theta = theta_s
A = [A, exp(-1i*2*pi*d*(0:M-1)'*sin(theta*pi/180))];
end
% Generate the signals
signals = randn(length(theta_s), N) + 1i*randn(length(theta_s), N);
% Add noise
noise = (randn(M, N) + 1i*randn(M, N))/sqrt(2);
X = A * signals + 10^(-SNR/20) * noise;
% Estimate the covariance matrix
R = (X * X') / N;
% Singular value decomposition
[U, S, V] = svd(R);
% Signal and noise subspace separation
signal_subspace = U(:, 1:length(theta_s));
noise_subspace = U(:, length(theta_s)+1:end);
% MUSIC spectrum
theta_scan = -90:0.1:90;
P_MUSIC = zeros(size(theta_scan));
for i = 1:length(theta_scan)
steering_vector = exp(-1i*2*pi*d*(0:M-1)'*sin(theta_scan(i)*pi/180));
P_MUSIC(i) = 1 / (steering_vector' * (noise_subspace * noise_subspace') * steering_vector);
end
% Plot MUSIC spectrum
P_MUSIC = 10*log10(abs(P_MUSIC) / max(abs(P_MUSIC)));
plot(theta_scan, P_MUSIC);
xlabel('Angle (degrees)');
ylabel('Spatial Spectrum (dB)');
title('MUSIC Spectrum using SVD');
grid on;
eig实现music算法
% Parameters
M = 8; % Number of array elements
N = 1000; % Number of snapshots
d = 0.5; % Distance between elements (in wavelengths)
theta_s = [30, 60]; % Signal directions (in degrees)
SNR = 20; % Signal-to-noise ratio (dB)
% Generate the steering matrix
A = [];
for theta = theta_s
A = [A, exp(-1i*2*pi*d*(0:M-1)'*sin(theta*pi/180))];
end
% Generate the signals
signals = randn(length(theta_s), N) + 1i*randn(length(theta_s), N);
% Add noise
noise = (randn(M, N) + 1i*randn(M, N))/sqrt(2);
X = A * signals + 10^(-SNR/20) * noise;
% Estimate the covariance matrix
R = (X * X') / N;
% Eigenvalue decomposition
[eigenvectors, eigenvalues] = eig(R);
eigenvalues = diag(eigenvalues);
% Sort the eigenvalues in descending order
[~, idx] = sort(eigenvalues, 'descend');
eigenvectors = eigenvectors(:, idx);
% Signal and noise subspace separation
signal_subspace = eigenvectors(:, 1:length(theta_s));
noise_subspace = eigenvectors(:, length(theta_s)+1:end);
% MUSIC spectrum
theta_scan = -90:0.1:90;
P_MUSIC = zeros(size(theta_scan));
for i = 1:length(theta_scan)
steering_vector = exp(-1i*2*pi*d*(0:M-1)'*sin(theta_scan(i)*pi/180));
P_MUSIC(i) = 1 / (steering_vector' * (noise_subspace * noise_subspace') * steering_vector);
end
% Plot MUSIC spectrum
P_MUSIC = 10*log10(abs(P_MUSIC) / max(abs(P_MUSIC)));
plot(theta_scan, P_MUSIC);
xlabel('Angle (degrees)');
ylabel('Spatial Spectrum (dB)');
title('MUSIC Spectrum');
grid on;