Dear Saed,
thank you very much for the reply. I know theoretically all these equation you mentioned in your reply. I have problems in simulating the probelm. My problem is simple than yours. I am considering a system where the signal cant reach directly from transmitter to receiver and a relay is emplyed in between to relay the signal from the sopurce to destination. I am mentioning below that how I am simulating the problem. If you can suggest anything, I'll be thankful to you.
After generating a bit sequence, I defined EbN0 values (say [-10:2:10]). Now i used these values to calculate N0(for each value of EbN0) and added noise to the transmitted signal using N0. I calculated SNR for 1st hop using SNR_hop1 = 10*(log10((Es1*alpha1)/N0)). where Es1=signal power and i have taken it as 1 for simplicity and alpha1 is the fading amplitude of the channel between Tx and Relay, i have also taken it 1. Do you think that i am right upto this point?
Now to transmit the signal from relay to destination, what should i do? should i define EbN0 again? and should it be same as before for Tx to relay case?
I have confusion at this point. Please if you can help me here? i am writing the code here, please see it and suggest me if you know about the problem more
clear all;
close all;
clc;
N = 10^6; % number of bits or symbols
inp = randint(1,N);% generating 0,1 with equal probability
bpsk_sig = 2*inp-1; % BPSK modulation 0 -> -1; 1 -> 0
Es1 = 1;
Es2 = 1; % Energies of symbols
omega1 = 1; omega2 = 1; % Average fading power of 1st and second hop respectively
%**********************************************************************
%**********************************************************************
Eb_N0_db_1 = [-10:1.5:15]; % multiple Eb/N0 values
for i = 1:length(Eb_N0_db_1);
N0_1 = 10^(-1*(Eb_N0_db_1(i)/10));
SNR_hop1(i,
= 10*(log10((Es1*omega1)/N0_1)) % N0 is used tocalculate SNR after 1st hop
% Noise addition
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise,1db variance
y1 = bpsk_sig + N0_1*n;
end
%**************************************************************************
% At relay
%**************************************************************************
Eb_N0_db_2 = [-10:1.5:15]; % multiple Eb/N0 values
for i = 1:length(Eb_N0_db_2);
N0_2 = 10^(-1*(Eb_N0_db_2(i)/10));
SNR_hop2(i,
= 10*(log10((Es2*omega2)/N0_2)) % N0 is used tocalculate SNR after 1st hop
% Noise addition
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)];
y2 = y1 + N0_2*n;
received = real(y2)>0;
% counting the errors
error(i) = size(find([inp- received]),2);
end
%**************************************************************************
% End-to-End SNR
%**************************************************************************
E2E_SNR = (SNR_hop1.*SNR_hop2)./(SNR_hop1 + SNR_hop2+1)
% [number_of_errors,bit_error_rate] = biterr(x,Received_Signal')
Pb_Error = error/N;
figure(4)
semilogy(E2E_SNR,Pb_Error,'ro-','LineWidth',2);grid on;hold on;
% semilogy(SNR_hop2,Pb_Error,'go-','LineWidth',2);grid on;hold off;