minimum variance distortionless response

조회 수: 13 (최근 30일)
salwa
salwa 2024년 12월 12일
댓글: salwa 2024년 12월 12일
anyone can help me why my code for mvdr error ?, the step of mvdr alghorithm:
s1 : compute the estimated covariance matrix Rxx of the incident signal vector x(n)
Rxx= E(x(n) . x(n)^H) =1/N. x(n). x(n)^H
signal modeled S = [s1, s2, ....., sm]^T
noise modeled No =[no1, no2, ..... uoL]^T
steering vector modeled A=[a(theta 1), a(theta 2),....,a(theta m)
a(theta m)= formula in the figure
the value of am is the angle at which the mic will be placed changing every experiment, one experiment will be placed at an angle (0,20,40,60,80,90,100,120,140,160,180,200, 220,240,260,270,300,320,340,360).
bm value obtained 10.2 degrees
s2 : Calculate the inverse matrix of the covariance matrix Rxx (Rxx-1)
s3: generate steering vector a(theta) as Equation for an angle theta.
s4 : Calculate the signal spectrum P(mvdr) for each value of theta from 0 to 360 degrees with the equation
Pmvdr (theta) 1/ a^H(theta) . Rxx^-1 . a(theta)
s5 : Determine the direction of arrival of the signal arrival direction obtained when the value of Pmvdr(theta) is maximal (or locally maximal if there are multiple sources).
s6: calculate the SNR value from the results to determine whether the SNR is high or low with the formula SNR = 10 .log 10 (S/N)
s7= calculate the MSE result from the results to find out whether the MSE is close to 0 or not MSE formula = ∑upper limit N and lower limit t=1 . (At-Ft)^2 /n
if what is processed by mvdr is in the form of sound samples obtained from 4 mic arrays
with the position of mic 1 at 0 degrees, mic 2 at 90 degrees, mic 3 at 270 degrees and mic 4 at 180 the sound will be in the form of 4 wav files to be processed, with lambda 0.5, Fs = 44100. from the step above, the correct MVDR matlab code will be made.
the incoming signal in the form of S will experience a phase difference so as to form a steering vector A and get additional noise with E{S.N^H}=10 in general the data model can be presented as follows x= AS+No
clear; clc; close all;
% Parameters
N = 4; % Number of microphone elements
d = 0.5; % Distance between microphone elements (in lambda)
theta = [90]; % Actual DoA angle (in degrees)
angles = 70:1:110; % Range of angles to estimate
Fs = 44100; % Sampling frequency
% Read .wav files from 4 microphones (ensure file paths are correct)
wavFiles = {'D:\MVDR\90\mic1.wav', 'D:\MVDR\90\mic2.wav', ...
'D:\MVDR\90\mic3.wav', 'D:\MVDR\90\mic4.wav'};
wavData = cell(1, N);
% Read sound data from each microphone
for i = 1:N
[data, Fs] = audioread(wavFiles{i});
wavData{i} = data;
end
% Determine the minimum signal length for alignment
signal_length = min(cellfun(@length, wavData));
for i = 1:N
wavData{i} = wavData{i}(1:signal_length); % Truncate to minimum length
end
% Combine data from all microphones
X_signal = zeros(N, signal_length);
for i = 1:N
X_signal(i, :) = wavData{i}.';
end
% Estimate the power of the original signal
signal_power = sum(abs(X_signal(:)).^2) / numel(X_signal);
% Set random seed for noise consistency
rng(42); % Set random generator seed
% Add noise to the signal
noise_level = 0.01; % Noise level relative to the signal
X_noise = noise_level * (randn(size(X_signal)) + 1j * randn(size(X_signal)));
X = X_signal + X_noise; % Received signal
% Calculate the actual SNR
noise_actual_power = sum(abs(X_noise(:)).^2) / numel(X_noise);
SNR_actual_dB = 10 * log10(signal_power / noise_actual_power);
% Calculate MSE
MSE = sum(abs(X(:) - X_signal(:)).^2) / numel(X_signal);
% Display SNR and MSE
disp(['Actual SNR: ', num2str(SNR_actual_dB), ' dB']);
disp(['MSE: ', num2str(MSE)]);
% Estimate the covariance matrix
R_xx = (1 / N) * (X * X'); % Covariance matrix of the input
% Compute the MVDR spectrum
P_mvdr = zeros(1, length(angles)); % Initialize MVDR spectrum
for i = 1:length(angles)
theta_angle = angles(i); % Angle being tested
% Steering vector a(theta) for angle theta
a_theta = exp(1j * 2 * pi * d * (0:N-1).' * sin(deg2rad(theta_angle)));
% Compute MVDR response
P_mvdr(i) = 1 / (a_theta' * (R_xx \ a_theta));
end
% Convert to dB
P_mvdr_dB = 10 * log10(abs(P_mvdr) / max(abs(P_mvdr)));
% Plot the sound signals from each microphone
figure;
for i = 1:N
subplot(N+1, 1, i);
t_wav = (1:signal_length) / Fs;
plot(t_wav, real(wavData{i}));
xlabel('Time (s)');
ylabel(['Mic ', num2str(i)]);
title(['Original Sound Signal - Microphone ', num2str(i)]);
grid on;
end
% Plot MVDR spectrum for estimated angles
subplot(N+1, 1, N+1);
plot(angles, P_mvdr_dB, 'LineWidth', 2);
xlabel('Angle (\theta) [degrees]');
ylabel('MVDR Spectrum (dB)');
title('Direction of Arrival Estimation Using MVDR');
grid on;
% Find the angle with the maximum power
[~, idx_max] = max(P_mvdr_dB);
theta_estimated = angles(idx_max);
disp(['Detected strongest source angle: ', num2str(theta_estimated), ' degrees']);
hold on;
plot(theta_estimated, P_mvdr_dB(idx_max), 'ro', 'MarkerFaceColor','r');
legend('MVDR Spectrum', ['Peak at \theta = ', num2str(theta_estimated), '°']);
% Plot with peak marker
figure;
plot(angles, P_mvdr_dB, 'LineWidth', 2);
hold on;
plot([theta_estimated, theta_estimated], ylim, '--r', 'LineWidth', 1.5); % Vertical line at peak detection
plot(theta_estimated, P_mvdr_dB(idx_max), 'ro', 'MarkerFaceColor','r'); % Point marker at peak detection
xlabel('Angle (\theta) [degrees]');
ylabel('MVDR Spectrum (dB)');
title('Direction of Arrival Estimation Using MVDR');
grid on;
legend('MVDR Spectrum', ['Peak at \theta = ', num2str(theta_estimated), '°']);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by