Correcting the error in Alamouti code (2 x 1)
I trying to code Alamouti code for BPSK in Rayleigh fading channel for BER simulation.There is a matrix dimention mismatch in decode section.I tried to correct it ,but it did not work.
Need your help to correct it.Thank you
clear all;
close all;
clc;
Ps = 1;%Transmit power
N = 10^6; % number of bits or symbols
NR = 1;
num_runs = 10;
snr_dB = -3:10 ; % in dB
rand(‘seed’,1); % initializing the rand() function so that random bits produced are same in every simulation
randn(‘seed’,1);
% Transmitter
x_data1 = rand(1,N/2)>0.5;
x_data2 = rand(1,N/2)>0.5;
binaryData = [x_data1; x_data2];
BPSK_data1 = 2*x_data1 – 1;
BPSK_data2 = 2*x_data2 – 1;
% BPSK modulation – 2×500000 matrix
BPSK_data =[BPSK_data1; BPSK_data2];
n1 = AWGN(1);
n2 = AWGN(1);
h1 = Rayleigh(1);
h2 = Rayleigh(1);
SNR = 10.^(snr_dB/10);
Noise_power = zeros(1,length(snr_dB));
for k = 1:length(snr_dB)
% Add complex AWGN noise power
Noise_power = Ps./SNR(k);
% In the first time slot, the received signal
y1 = h1.*BPSK_data1 + h2.*BPSK_data2 + n1;
% In the first time slot, the received signal
y2 = h1.*(-conj(BPSK_data2)) + h2.*(conj(BPSK_data1)) + n2;
%Rayleigh fading channel – 2×1 matrix
H = [h1 h2 ; conj(h2) -conj(h1)];
%Decode the sysmbols – ZF decoder
x1_hat = pinv(H).*y1;
x2_hat = pinv(H).*conj(y2);
rx_bits = [x1_hat;x2_hat];
rx_bits = real(rx_bits) > 0;
% Count errors
nErr(k) = size(find(binaryData – rx_bits),1);
end
% counting the errors
ber = nErr/N; % simulated ber
figure(1);
semilogy(snr_dB,ber,’b.-‘);
% axis([0 10 10^-4 0.6])
grid on;
legend( ‘MIMO – BER’);
xlabel(‘SNR[dB]’);
ylabel(‘Bit Error Rate’);
title(‘BER for MIMO-BPSK’);
%%%%% AWGN noise %%%%%
function n = AWGN(N)
n = rand(1,N);
end
%%%%% Rayleigh channel %%%%%%
function h = Rayleigh(N);
x = sqrt(1/2).*rand(1,N);
y = sqrt(1/2).*rand(1,N);
h = abs(x + i*y);
endI trying to code Alamouti code for BPSK in Rayleigh fading channel for BER simulation.There is a matrix dimention mismatch in decode section.I tried to correct it ,but it did not work.
Need your help to correct it.Thank you
clear all;
close all;
clc;
Ps = 1;%Transmit power
N = 10^6; % number of bits or symbols
NR = 1;
num_runs = 10;
snr_dB = -3:10 ; % in dB
rand(‘seed’,1); % initializing the rand() function so that random bits produced are same in every simulation
randn(‘seed’,1);
% Transmitter
x_data1 = rand(1,N/2)>0.5;
x_data2 = rand(1,N/2)>0.5;
binaryData = [x_data1; x_data2];
BPSK_data1 = 2*x_data1 – 1;
BPSK_data2 = 2*x_data2 – 1;
% BPSK modulation – 2×500000 matrix
BPSK_data =[BPSK_data1; BPSK_data2];
n1 = AWGN(1);
n2 = AWGN(1);
h1 = Rayleigh(1);
h2 = Rayleigh(1);
SNR = 10.^(snr_dB/10);
Noise_power = zeros(1,length(snr_dB));
for k = 1:length(snr_dB)
% Add complex AWGN noise power
Noise_power = Ps./SNR(k);
% In the first time slot, the received signal
y1 = h1.*BPSK_data1 + h2.*BPSK_data2 + n1;
% In the first time slot, the received signal
y2 = h1.*(-conj(BPSK_data2)) + h2.*(conj(BPSK_data1)) + n2;
%Rayleigh fading channel – 2×1 matrix
H = [h1 h2 ; conj(h2) -conj(h1)];
%Decode the sysmbols – ZF decoder
x1_hat = pinv(H).*y1;
x2_hat = pinv(H).*conj(y2);
rx_bits = [x1_hat;x2_hat];
rx_bits = real(rx_bits) > 0;
% Count errors
nErr(k) = size(find(binaryData – rx_bits),1);
end
% counting the errors
ber = nErr/N; % simulated ber
figure(1);
semilogy(snr_dB,ber,’b.-‘);
% axis([0 10 10^-4 0.6])
grid on;
legend( ‘MIMO – BER’);
xlabel(‘SNR[dB]’);
ylabel(‘Bit Error Rate’);
title(‘BER for MIMO-BPSK’);
%%%%% AWGN noise %%%%%
function n = AWGN(N)
n = rand(1,N);
end
%%%%% Rayleigh channel %%%%%%
function h = Rayleigh(N);
x = sqrt(1/2).*rand(1,N);
y = sqrt(1/2).*rand(1,N);
h = abs(x + i*y);
end I trying to code Alamouti code for BPSK in Rayleigh fading channel for BER simulation.There is a matrix dimention mismatch in decode section.I tried to correct it ,but it did not work.
Need your help to correct it.Thank you
clear all;
close all;
clc;
Ps = 1;%Transmit power
N = 10^6; % number of bits or symbols
NR = 1;
num_runs = 10;
snr_dB = -3:10 ; % in dB
rand(‘seed’,1); % initializing the rand() function so that random bits produced are same in every simulation
randn(‘seed’,1);
% Transmitter
x_data1 = rand(1,N/2)>0.5;
x_data2 = rand(1,N/2)>0.5;
binaryData = [x_data1; x_data2];
BPSK_data1 = 2*x_data1 – 1;
BPSK_data2 = 2*x_data2 – 1;
% BPSK modulation – 2×500000 matrix
BPSK_data =[BPSK_data1; BPSK_data2];
n1 = AWGN(1);
n2 = AWGN(1);
h1 = Rayleigh(1);
h2 = Rayleigh(1);
SNR = 10.^(snr_dB/10);
Noise_power = zeros(1,length(snr_dB));
for k = 1:length(snr_dB)
% Add complex AWGN noise power
Noise_power = Ps./SNR(k);
% In the first time slot, the received signal
y1 = h1.*BPSK_data1 + h2.*BPSK_data2 + n1;
% In the first time slot, the received signal
y2 = h1.*(-conj(BPSK_data2)) + h2.*(conj(BPSK_data1)) + n2;
%Rayleigh fading channel – 2×1 matrix
H = [h1 h2 ; conj(h2) -conj(h1)];
%Decode the sysmbols – ZF decoder
x1_hat = pinv(H).*y1;
x2_hat = pinv(H).*conj(y2);
rx_bits = [x1_hat;x2_hat];
rx_bits = real(rx_bits) > 0;
% Count errors
nErr(k) = size(find(binaryData – rx_bits),1);
end
% counting the errors
ber = nErr/N; % simulated ber
figure(1);
semilogy(snr_dB,ber,’b.-‘);
% axis([0 10 10^-4 0.6])
grid on;
legend( ‘MIMO – BER’);
xlabel(‘SNR[dB]’);
ylabel(‘Bit Error Rate’);
title(‘BER for MIMO-BPSK’);
%%%%% AWGN noise %%%%%
function n = AWGN(N)
n = rand(1,N);
end
%%%%% Rayleigh channel %%%%%%
function h = Rayleigh(N);
x = sqrt(1/2).*rand(1,N);
y = sqrt(1/2).*rand(1,N);
h = abs(x + i*y);
end matlab, mimo, wireless, alamouti code MATLAB Answers — New Questions