sarmadalani
Newbie level 3
Hello everyone I have made the following code but there was a problem and am seeking help
% the first task is to generate a bpsk signal and simulate the BER and the second task is to convert this to MIMO
clear;clc;
N = 1e4; % Number of data bits
Nt = 1; % Number of Tx antennas
Nr = 1; % Number of Rx antennas
SNR = 0:2:20; % Signal to Noise Ratio range
x = sign (randn(Nt,N)); % BPSK data signal generation
for mm = 1:length(SNR)
Y=0;
Pe = 0;
for i = 1:10000
H = sqrt(1/2) * (randn(Nr,Nt) + j*(randn(Nr,Nt))); % Rayleigh channel
[ U L V ] = svd(H); % Singular Value Decomposition
n = sqrt(1/2)*(10^(-SNR(mm)/10)) * (randn(Nr,N) + j*(randn(Nr,N))); % Additive White Gaussian Noise, 0dB Variance
y = (L*x)+ n; % Channel and Noise addition
Y = y./L; % Equalization
Ydig = sign(real(Y)); %%l ine 17
Diff = (x - Ydig)/2;
AbsDiff = abs(Diff);
Err = sum(AbsDiff);
Pe = Pe + Err;
end
mm
Per(mm) = (Pe)/(N*10000);
end
semilogy(SNR,Per,'-g*')
hold on
grid on
xlabel('SNR, dB')
ylabel('Bit Error Rate')
title('BER for BPSK in a Rayleigh channel')
The problem is when I change Nt & Nr to 4 instead of 1 the following error occur
Error using ==> rdivide Matrix dimensions must agree. Error in ==> test1 at 16 Y = y./L;
What I want to do is change Nt & Nr to 4, them make sum to y so the matrix will be in 1 row then divide by 4 and then do error count starting from line 17
thanks in advance
% the first task is to generate a bpsk signal and simulate the BER and the second task is to convert this to MIMO
clear;clc;
N = 1e4; % Number of data bits
Nt = 1; % Number of Tx antennas
Nr = 1; % Number of Rx antennas
SNR = 0:2:20; % Signal to Noise Ratio range
x = sign (randn(Nt,N)); % BPSK data signal generation
for mm = 1:length(SNR)
Y=0;
Pe = 0;
for i = 1:10000
H = sqrt(1/2) * (randn(Nr,Nt) + j*(randn(Nr,Nt))); % Rayleigh channel
[ U L V ] = svd(H); % Singular Value Decomposition
n = sqrt(1/2)*(10^(-SNR(mm)/10)) * (randn(Nr,N) + j*(randn(Nr,N))); % Additive White Gaussian Noise, 0dB Variance
y = (L*x)+ n; % Channel and Noise addition
Y = y./L; % Equalization
Ydig = sign(real(Y)); %%l ine 17
Diff = (x - Ydig)/2;
AbsDiff = abs(Diff);
Err = sum(AbsDiff);
Pe = Pe + Err;
end
mm
Per(mm) = (Pe)/(N*10000);
end
semilogy(SNR,Per,'-g*')
hold on
grid on
xlabel('SNR, dB')
ylabel('Bit Error Rate')
title('BER for BPSK in a Rayleigh channel')
The problem is when I change Nt & Nr to 4 instead of 1 the following error occur
Error using ==> rdivide Matrix dimensions must agree. Error in ==> test1 at 16 Y = y./L;
What I want to do is change Nt & Nr to 4, them make sum to y so the matrix will be in 1 row then divide by 4 and then do error count starting from line 17
thanks in advance