Mimo Code
Mimo Code
% Create two comm.AWGNChannel System objects for one and two receive
% antennas respectively. Set the NoiseMethod property of the channel to
% 'Signal to noise ratio (Eb/No)' to specify the noise level using the
% energy per bit to noise power spectral density ratio (Eb/No). The output
% of the BPSK modulator generates unit power signals; set the SignalPower
% property to 1 Watt.
awgn1Rx = comm.AWGNChannel(...
'NoiseMethod', 'Signal to noise ratio (Eb/No)', ...
'SignalPower', 1);
awgn2Rx = clone(awgn1Rx);
ax.YScale = 'log';
xlim(ax,[EbNo(1), EbNo(end)]);
ylim(ax,[1e-4 1]);
xlabel(ax,'Eb/No (dB)');
ylabel(ax,'BER');
fig.NumberTitle = 'off';
fig.Renderer = 'zbuffer';
fig.Name = 'Transmit vs. Receive Diversity';
title(ax,'Transmit vs. Receive Diversity');
set(fig, 'DefaultLegendAutoUpdate', 'off');
fig.Position = figposition([15 50 25 30]);
% Modulate data
modData = bpskMod(data);
% Add AWGN
rxSig11 = awgn1Rx(chanOut11);
rxSig21 = awgn1Rx(chanOut21);
rxSig12 = awgn2Rx(chanOut12);
% Plot results
semilogy(ax,EbNo(1:idx), ber_noDiver(1,1:idx), 'r*', ...
EbNo(1:idx), ber_Alamouti(1,1:idx), 'go', ...
EbNo(1:idx), ber_MaxRatio(1,1:idx), 'bs', ...
EbNo(1:idx), ber_thy2(1:idx), 'm');
legend(ax,'No Diversity (1Tx, 1Rx)', 'Alamouti (2Tx, 1Rx)',...
'Maximal-Ratio Combining (1Tx, 2Rx)', ...
'Theoretical 2nd-Order Diversity');
drawnow;
end % end of for loop for EbNo