Please help to fix this problem. I try to plot as semilogy the MRC in Rayleigh fading and BPSK scheme. This needs to display in the same figure the simBer1 in M_Rx=1, 2, 3 with M_Rx=1 in 0:2:12; M_Rx2=0:2:14; M_Rx=3 in 0:2:16
ip = rand(1,N)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % 0 -> -1; 1 -> 0 >> BPSK modulation
nRx_max = 3; %number of M branches
M_Rx = [1:nRx_max];EbN0dB1 = [0:2:12]; EbN0dB2 = [0:2:14]; EbN0dB3 = [0:2:16];%%%%% EGC %%%%%%%%%%%
for jj = 1:length(M_Rx) %%%Common values
for k = 1:length(EbN0dB1) n = 1/sqrt(2)*[randn(M_Rx(jj),N) + j*randn(M_Rx(jj),N)]; % White gaussian noise, 0dB variance
h = 1/sqrt(2)*[randn(M_Rx(jj),N) + j*randn(M_Rx(jj),N)]; % Rayleigh fading channel
% Channel and noise Noise addition
sD = kron(ones(M_Rx(jj),1),s); %%% In different values of dBN0dB
y1 = h.*sD + 10^(-EbN0dB1(k)/20)*n; %%%%% EbN0dB1 = [0:2:14] %%%%%%%%%%%
% equalization with EGC
y1Hat = y1.*exp(-j*angle(h)); % removing the phase of the channel
y1Hat = sum(y1Hat,1); % adding values from all the receive chains
% receiver Rx
ip1Hat = real(y1Hat)>0; % numbers the errors
nErr1(jj,k) = size(find([ip- ip1Hat]),2); endend%theoryBer_nRx1 = 0.5.*(1-1*(1+1./EbN0Lin1).^(-0.5));
%theoryBer_nRx2 = 0.5*(1 - sqrt(EbN0Lin1.*(EbN0Lin1+2))./(EbN0Lin1+1) );
simBer1 = nErr1/N; % simulated ber
EbN0Lin1 = 10.^(EbN0dB1/10); %EbN0 linear
close allfigure(1)semilogy(EbN0dB1,simBer1(1,:),'mo-','LineWidth',1);hold on;semilogy(EbN0dB2,simBer1(2,:),'kp-','LineWidth',1);semilogy(EbN0dB3,simBer1(3,:),'gs-','LineWidth',1);grid onlegend('M=1', 'M=2', 'M=3');xlabel('Eb/No, dB');ylabel('Bit Error Rate');title('BER for BPSK modulation with Equal Gain Combining in Rayleigh channel');axis([0 20 10^-6 2])
Error using semilogy
Vectors must be the same length.
Error in MRC_bpsk.m (line 41)
semilogy(EbN0dB2,simBer1(2,:),'kp-','LineWidth',1);
>>
Best Answer