Skip to main content

MVDR in MATLAB

 

MATLAB Code

clc; clear; close all;
%% Step 1: Define Parameters
M = 8; % Number of array sensors
d = 0.5; % Sensor spacing (lambda/2)
K = 2; % Number of sources
N = 200; % Number of snapshots
theta = [-20 30]; % True signal angles (degrees)
SNR = 10; % Signal-to-noise ratio (dB)
fprintf('Step 1: Parameters Initialized\n');
%% Step 2: Generate Source Signals
t = 1:N;
s1 = exp(1j*2*pi*0.05*t); % Source 1
s2 = exp(1j*2*pi*0.1*t); % Source 2
S = [s1; s2];
figure;
plot(real(S(1,:))); title('Signal 1 (Real Part)'); xlabel('Samples'); ylabel('Amplitude');
figure;
plot(real(S(2,:))); title('Signal 2 (Real Part)'); xlabel('Samples'); ylabel('Amplitude');
fprintf('Step 2: Source Signals Generated\n');
%% Step 3: Construct Steering Matrix
A = zeros(M,K);
for k = 1:K
A(:,k) = exp(-1j*2*pi*d*(0:M-1)'*sin(theta(k)*pi/180));
end
fprintf('Step 3: Steering Matrix Created\n');
%% Step 4: Generate Received Signals with Noise
X = A*S;
noise = (randn(M,N) + 1j*randn(M,N))/sqrt(2);
noise = noise * 10^(-SNR/20);
X = X + noise;
figure;
plot(real(X(1,:))); title('Received Signal at Sensor 1'); xlabel('Samples'); ylabel('Amplitude');
fprintf('Step 4: Received Signals with Noise Generated\n');
%% Step 5: Estimate Covariance Matrix
R = (X*X')/N;
figure;
imagesc(abs(R)); colorbar; title('Covariance Matrix Magnitude'); xlabel('Sensors'); ylabel('Sensors');
fprintf('Step 5: Covariance Matrix Computed\n');
%% Step 6: Eigenvalue Decomposition
[Evec, Eval] = eig(R);
eigenvalues = diag(Eval);
figure;
stem(sort(eigenvalues,'descend')); title('Eigenvalues of Covariance Matrix'); xlabel('Index'); ylabel('Eigenvalue');
fprintf('Step 6: Eigen Decomposition Done\n');
%% Step 7: Sort Eigenvalues and Eigenvectors
[eigenvalues_sorted, idx] = sort(eigenvalues,'descend');
Evec_sorted = Evec(:,idx);
fprintf('Step 7: Eigenvalues Sorted\n');
%% Step 8: Separate Signal and Noise Subspace
Es = Evec_sorted(:,1:K); % Signal subspace
En = Evec_sorted(:,K+1:end); % Noise subspace
fprintf('Step 8: Signal and Noise Subspaces Separated\n');
%% Step 9: MUSIC Spectrum Calculation
angles = -90:0.1:90;
Pmusic = zeros(size(angles));
for i = 1:length(angles)
steering = exp(-1j*2*pi*d*(0:M-1)'*sin(angles(i)*pi/180));
Pmusic(i) = 1/(steering'*(En*En')*steering); % MUSIC denominator
end
Pmusic = abs(Pmusic);
Pmusic = 10*log10(Pmusic/max(Pmusic));
figure;
plot(angles,Pmusic,'LineWidth',2); grid on;
xlabel('Angle (degrees)'); ylabel('Spectrum (dB)'); title('MUSIC Spatial Spectrum');
fprintf('Step 9: MUSIC Spectrum Computed\n');
%% Step 10: MVDR Beamforming to Reconstruct Sources
S_beamformed = zeros(K,N); % Preallocate
for k = 1:K
a_k = A(:,k); % Steering vector for k-th source
% MVDR weights
w_mvdr = (R\ a_k) / (a_k' * (R\ a_k));
% Apply beamforming
S_beamformed(k,:) = w_mvdr' * X;
end
% Plot MVDR beamformed signals
figure;
for k=1:K
subplot(K,1,k);
plot(real(S_beamformed(k,:)));
title(['MVDR Beamformed Signal ', num2str(k)]);
xlabel('Sample'); ylabel('Amplitude');
end
fprintf('Step 10: MVDR Beamforming Completed\n');

Output

 

 

 

 

 

 

 

 


Workflow of the Multi-Antenna Signal Processing and MUSIC/MVDR Code

This section describes the step-by-step workflow of the MATLAB code that simulates multiple sources, separates them using subspace methods, and reconstructs signals via MVDR beamforming.

  1. Step 1: Parameter Initialization

    Define key parameters including:

    • Number of array sensors (M)
    • Sensor spacing (d)
    • Number of sources (K)
    • Number of snapshots (N)
    • True source angles (theta)
    • Signal-to-noise ratio (SNR)

    These parameters form the foundation for the simulation.

  2. Step 2: Generate Source Signals

    Create narrowband complex exponential signals representing the sources:

    s1 = exp(1j*2*pi*0.05*t);
    s2 = exp(1j*2*pi*0.1*t);

    These signals form the source matrix S.

  3. Step 3: Construct Steering Matrix

    Compute the steering vectors for each source direction and form the matrix A. Each column represents the array’s response to a source angle.

  4. Step 4: Generate Received Signals

    The array receives a combination of source signals and additive noise:

    X = A*S + noise;

    This models the real-world scenario of multiple antennas capturing overlapping signals with noise.

  5. Step 5: Covariance Matrix Estimation

    Compute the sample covariance matrix of the received signals:

    R = (X*X')/N;

    This matrix captures correlations between sensors and is essential for subspace separation.

  6. Step 6: Eigenvalue Decomposition

    Decompose the covariance matrix into eigenvalues and eigenvectors:

    [Evec, Eval] = eig(R);

    Eigenvalues indicate the power in each subspace, separating signal and noise components.

  7. Step 7: Sort Eigenvalues and Eigenvectors

    Sort eigenvalues in descending order to identify the signal subspace (largest eigenvalues) and noise subspace (smallest eigenvalues).

  8. Step 8: Subspace Separation

    Define:

    • Signal subspace: Es = Evec_sorted(:,1:K)
    • Noise subspace: En = Evec_sorted(:,K+1:end)

    Noise and signal subspaces are orthogonal, which is the foundation for MUSIC.

  9. Step 9: MUSIC Spectrum Calculation

    Scan angles using steering vectors and compute the pseudo-spectrum:

    Pmusic(i) = 1/(steering'*(En*En')*steering);

    Peaks in the spectrum indicate the directions of arrival (DOAs) of the sources.

  10. Step 10: MVDR Beamforming

    For each source, apply MVDR weights to reconstruct the signal while minimizing noise:

    w_mvdr = (R\ a_k) / (a_k' * (R\ a_k));
    S_beamformed(k,:) = w_mvdr' * X;

    This produces clean estimates of each source signal from the mixed array observations.

Summary: The workflow models a practical multi-antenna system: simulate sources, capture them with an array, compute correlations, separate signal/noise subspaces, find DOAs (MUSIC), and reconstruct signals (MVDR beamforming). This closely mimics real-world array signal processing in radar, wireless communications, and MIMO systems.

People are good at skipping over material they already know!

View Related Topics to







Contact Us

Name

Email *

Message *

Popular Posts

ASK, FSK, and PSK (with MATLAB + Online Simulator)

📘 Overview 📘 Amplitude Shift Keying (ASK) 📘 Frequency Shift Keying (FSK) 📘 Phase Shift Keying (PSK) 📘 Which of the modulation techniques—ASK, FSK, or PSK—can achieve higher bit rates? 🧮 MATLAB Codes 📘 Simulator for binary ASK, FSK, and PSK Modulation 📚 Further Reading ASK or OFF ON Keying ASK is a simple (less complex) Digital Modulation Scheme where we vary the modulation signal's amplitude or voltage by the message signal's amplitude or voltage. We select two levels (two different voltage levels) for transmitting modulated message signals. For example, "+5 Volt" (upper level) and "0 Volt" (lower level). To transmit binary bit "1", the transmitter sends "+5 Volts", and for bit "0", it sends no power. The receiver uses filters to detect whether a binary "1" or "0" was transmitted. ...

BER vs SNR for M-ary QAM, M-ary PSK, QPSK, BPSK, ...(MATLAB Code + Simulator)

📘 Overview of BER and SNR 🧮 Online Simulator for BER calculation 🧮 MATLAB Code for BER calculation 📚 Further Reading 📂 View Other Topics on M-ary QAM, M-ary PSK, QPSK ... 🧮 Online Simulator for Constellation Diagram of m-ary QAM 🧮 Online Simulator for Constellation Diagram of m-ary PSK 🧮 MATLAB Code for BER calculation of ASK, FSK, and PSK 🧮 MATLAB Code for BER calculation of Alamouti Scheme 🧮 Different approaches to calculate BER vs SNR What is Bit Error Rate (BER)? The abbreviation BER stands for Bit Error Rate, which indicates how many corrupted bits are received compared to the total number of bits sent. BER = (number of bits received in error) / (total number of transmitted bits) What is Signal-to-Noise Ratio (SNR)? SNR is the ratio of signal power to noise powe...

Calculation of SNR from FFT bins in MATLAB

📘 Overview 🧮 MATLAB Code for Estimation of SNR from FFT bins 🧮 MATLAB Code for SNR from PSD using Kaiser Window 📚 Further Reading Here, you can find the SNR of a received signal from periodogram / FFT bins using the Kaiser operator. The beta (β) parameter characterizes the Kaiser window, which controls the trade-off between the main lobe width and the side lobe level. Steps Set up the sampling rate and time vector Compute the FFT and periodogram Calculate the frequency resolution and signal power Exclude the signal power from noise calculation Compute the noise power and SNR MATLAB Code for Estimation of SNR from FFT bins clc; clear; close all; % Parameters fs = 8000; f_tone = 1000; N = 8192; t = (0:N-1)/fs; % Generate signal + noise signal = sin(2*pi*f_tone*t); SNR_true_dB = 20; signal_power = mean(signal.^2); noise_power = signal_power / (10^(SNR_true_dB/10)); noisy_signal = signal + sqrt(noise_power) * randn(1, N); % Apply ...

MATLAB Code for ASK, FSK, and PSK (with Online Simulator)

📘 Overview & Theory 🧮 MATLAB Code for ASK 🧮 MATLAB Code for FSK 🧮 MATLAB Code for PSK 🧮 Simulator for binary ASK, FSK, and PSK Modulations 📚 Further Reading ASK, FSK & PSK HomePage MATLAB Code MATLAB Code for ASK Modulation and Demodulation % The code is written by SalimWireless.Com % Clear previous data and plots clc; clear all; close all; % Parameters Tb = 1; % Bit duration (s) fc = 10; % Carrier frequency (Hz) N_bits = 10; % Number of bits Fs = 100 * fc; % Sampling frequency (ensure at least 2*fc, more for better representation) Ts = 1/Fs; % Sampling interval samples_per_bit = Fs * Tb; % Number of samples per bit duration % Generate random binary data rng(10); % Set random seed for reproducibility binary_data = randi([0, 1], 1, N_bits); % Generate random binary data (0 or 1) % Initialize arrays for continuous signals t_overall = 0:Ts:(N_bits...

Online Simulator for ASK, FSK, and PSK

Try our new Digital Signal Processing Simulator!   Start Simulator for binary ASK Modulation Message Bits (e.g. 1,0,1,0) Carrier Frequency (Hz) Sampling Frequency (Hz) Run Simulation Simulator for binary FSK Modulation Input Bits (e.g. 1,0,1,0) Freq for '1' (Hz) Freq for '0' (Hz) Sampling Rate (Hz) Visualize FSK Signal Simulator for BPSK Modulation ...

Constellation Diagrams of ASK, PSK, and FSK with MATLAB Code + Simulator

📘 Overview of Energy per Bit (Eb / N0) 🧮 Online Simulator for constellation diagrams of ASK, FSK, and PSK 🧮 Theory behind Constellation Diagrams of ASK, FSK, and PSK 🧮 MATLAB Codes for Constellation Diagrams of ASK, FSK, and PSK 📚 Further Reading 📂 Other Topics on Constellation Diagrams of ASK, PSK, and FSK ... 🧮 Simulator for constellation diagrams of m-ary PSK 🧮 Simulator for constellation diagrams of m-ary QAM BASK (Binary ASK) Modulation: Transmits one of two signals: 0 or -√Eb, where Eb​ is the energy per bit. These signals represent binary 0 and 1.    BFSK (Binary FSK) Modulation: Transmits one of two signals: +√Eb​ ( On the y-axis, the phase shift of 90 degrees with respect to the x-axis, which is also termed phase offset ) or √Eb (on x-axis), where Eb​ is the energy per bit. These signals represent binary 0 and 1.  BPSK (Binary PSK) Modulation: Transmits one of two signals...

Comparing Baseband and Passband Implementations of ASK, FSK, and PSK

📘 Overview 🧮 Baseband and Passband Implementations of ASK, FSK, and PSK 🧮 Difference betwen baseband and passband 📚 Further Reading 📂 Other Topics on Baseband and Passband ... 🧮 Baseband modulation techniques 🧮 Passband modulation techniques   Baseband modulation techniques are methods used to encode information signals onto a baseband signal (a signal with frequencies close to zero). Passband techniques shift these signals to higher carrier frequencies for transmission. Here are the common implementations: Amplitude Shift Keying (ASK) [↗] : In ASK, the amplitude of the signal is varied to represent different symbols. Binary ASK (BASK) is a common implementation where two different amplitudes represent binary values (0 and 1). ASK is simple but susceptible to noise. ASK Baseband (Digital Bits) ASK Passband (Modulated Carrier)     Fig 1:  ASK Passband Modulation (...

LDPC Encoding and Decoding Techniques

📘 Overview & Theory 🧮 LDPC Encoding Techniques 🧮 LDPC Decoding Techniques 📚 Further Reading 'LDPC' is the abbreviation for 'low density parity check'. LDPC code H matrix contains very few amount of 1's and mostly zeroes. LDPC codes are error correcting code. Using LDPC codes, channel capacities that are close to the theoretical Shannon limit can be achieved.  Low density parity check (LDPC) codes are linear error-correcting block code suitable for error correction in a large block sizes transmitted via very noisy channel. Applications requiring highly reliable information transport over bandwidth restrictions in the presence of noise are increasingly using LDPC codes. 1. LDPC Encoding Technique The proper form of H matrix is derived from the given matrix by doing multiple row operations as shown above. In the above, H is parity check matrix and G is generator matrix. If you consider matrix H as [-P' | I] then matrix G will b...