wireless communication system simulation
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291777/image.png)
clc;
clear all;
close all;
% Initialization
Nw = 1; % noise variance
M = 50 ; % symbol period of the tag
Mt = 4; % training symbols
al = 0.5 ; % alpha is tag coefficient
L = 1000;
N_mc = 10^6;
N = 50; % comsecutive samples of s(n)
RCD = 0.5;% Relative channel difference.
SNRdB = 0:5:20;
%%% initialisation complete%%%%%%%%%%%%
% Radio frequency source transmitting signal s(n)
sn = sqrt(1/2)*(randn(1,L)+1i*randn(1,L));
Ps = 1; % RF source signal power
% channels and AWGN noise
hsr = sqrt(1/2)*(randn(1,L)+1i*randn(1,L)); % channel between source and reader
hst = sqrt(1/2)*(randn(1,L)+1i*randn(1,L));% channel between source and tag
vn = 10;
htr = sqrt(vn/2)*(randn(1,L)+1i*randn(1,L)); % channel between tag and reader
wn = sqrt(1/2)*(randn(1,L)+1i*randn(1,L)); % AWGN noise
% Thresholds
ho = hsr;
ho_abs = sqrt(sum(abs(ho).^2));
so2 = (((ho_abs)^2)*Ps)+Nw;% sigma_o square
h1 = (hsr)+ (al*(hst.*htr));
h1_abs = sqrt(sum(abs(h1).^2));
s12 = (((h1_abs)^2)*Ps)+Nw; % sigma_1 square
Nid = 10^2 ;% number of incorrect bit decisions
% Reader / receiver
for n = 1:length (SNRdB)
errcnt = 0;
bitcnt = 0;
while errcnt < Nid
d = (rand > 1/2); % tag
if d == 0
y = ((hsr + al*(hst.*htr)*d).*sn)+ 10^(-SNRdB(n)/20)* wn;
ybar = y(1:N);
z = norm(ybar);
Z = z^2;
end
if d == 1
y = ((hsr + al*(hst.*htr)*d).*sn)+ 10^(-SNRdB(n)/20)* wn;
ybar = y(1:N);
z = norm(ybar);
Z = z^2;
end
ho = hsr;
ho_abs = sqrt(sum(abs(ho).^2));
so2 = (((ho_abs)^2)*Ps)+Nw;% sigmao square
h1 = (hsr)+ (al*(hst.*htr));
h1_abs = sqrt(sum(abs(h1).^2));
s12 = (((h1_abs)^2)*Ps)+Nw; % sigma1 square
ThCG = ((N*so2*s12)/(s12-so2))*log(s12/so2); % threshold for complex gaussian optimal detector.
if so2 > s12
if Z > ThCG
dhat = 0;
else
dhat = 1;
end
end
if so2 < s12
if Z < ThCG
dhat = 0;
else
dhat = 1;
end
end
if dhat ~= d
errcnt = errcnt+1;
end
bitcnt = bitcnt+1;
end
BER(n) = errcnt/bitcnt;
end
figure
semilogy(SNRdB,BER);
grid on;
xlabel('SNRdB');
ylabel('Bit Error Rate');
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Sources and Sinks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!