Design 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

DESIGN THINKING

GROUP 13:MATLAB program to simulate Maximal Ratio Combining technique

% Maximal Ratio Combining (MRC) Simulation


clc;
clear all;
close all;
% Number of antennas
numAntennas = 2;

% Number of samples
numSamples = 1000;

% Channel gains (complex numbers)


h1 = (randn(1, numSamples) + 1i * randn(1, numSamples)) / sqrt(2);
h2 = (randn(1, numSamples) + 1i * randn(1, numSamples)) / sqrt(2);

% Received signals (assuming a transmitted signal of 1 for simplicity)


x = ones(1, numSamples);

% Generate complex Gaussian noise


noise = (randn(numAntennas, numSamples) + 1i * randn(numAntennas, numSamples))
/ sqrt(2);

% Received signals at each antenna


y1 = h1 .* x + noise(1, :);
y2 = h2 .* x + noise(2, :);

% Maximal Ratio Combining (MRC) weights


w1 = conj(h1);
w2 = conj(h2);

% Combined signal using MRC


y_mrc = w1 .* y1 + w2 .* y2;

% Display results
figure;
subplot(3,1,1);
plot(real(y1), 'b');
hold on;
plot(real(y2), 'r');
title('Received Signals at Each Antenna');
legend('Antenna 1', 'Antenna 2');
xlabel('Sample Index');
ylabel('Amplitude');

subplot(3,1,2);
plot(real(y_mrc), 'g');
title('Combined Signal using MRC');
xlabel('Sample Index');
ylabel('Amplitude');

subplot(3,1,3);
plot(10*log10(abs(y1).^2), 'b');
hold on;
plot(10*log10(abs(y2).^2), 'r');
plot(10*log10(abs(y_mrc).^2), 'g');
DESIGN THINKING

title('Power Spectra');
legend('Antenna 1', 'Antenna 2', 'MRC');
xlabel('Sample Index');
ylabel('Power (dB)');
DESIGN THINKING

You might also like