1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
function pfeCode
% Création de l'objet Figure
figure('units','pixels',...
'position',[50 50 1000 700],...
'color',[0.5 0.5 0.8],...
'numbertitle','off',...
'name','Démodulateur Satellite',...
'menubar','none',...
'tag','interface');
% Création de l'objet UicontrolPushbutton sortie QAM
uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.02 0.4 0.07 0.07],...
'string','QAM',...
'callback',@ajouter1,...
'tag','bouton1-');
end
function ajouter1(~,~)
%%with noise
% Frame Length
bit_count = 10000;
% Range of SNR over which to simulate
Eb_No = -3: 1: 30;
% Convert Eb/No values to channel SNR
% Consult BERNARD SKLAR'S book 'Digital Communications'
SNR = Eb_No + 10*log10(2);
% Start the main calculation loop
for aa = 1: 1: length(SNR)
% Initiate variables
T_Errors = 0;
T_bits = 0;
% Keep going until you get 100 errors
while T_Errors < 100
% Generate some random bits
uncoded_bits = round(rand(1,bit_count));
% Split the stream into 4 substreams
B = reshape(uncoded_bits,4,length(uncoded_bits)/4);
B1 = B(1,:);
B2 = B(2,:);
B3 = B(3,:);
B4 = B(4,:);
% 16-QAM modulator
% normalizing factor
a = sqrt(1/10);
% bit mapping
tx = a*(-2*(B3-0.5).*(3-2*B4)-j*2*(B1-0.5).*(3-2*B2));
% Variance = 0.5 - Tracks theoritical PDF closely
ray = sqrt((1/2)*((randn(1,length(tx))).^2+(randn(1,length(tx))).^2));
% Include The Fading
rx = tx.*ray;
% Noise variance
N0 = 1/10^(SNR(aa)/10);
% Send over Gaussian Link to the receiver
rx = rx + sqrt(N0/2)*(randn(1,length(tx))+1i*randn(1,length(tx)));
%---------------------------------------------------------------
% Equaliser
rx = rx./ray;
% 16-QAM demodulator at the Receiver
a = 1/sqrt(10);
B5 = imag(rx)<0;
B6 = (imag(rx)<2*a) & (imag(rx)>-2*a);
B7 = real(rx)<0;
B8 = (real(rx)<2*a) & (real(rx)>-2*a);
% Merge into single stream again
temp = [B5;B6;B7;B8];
B_hat = reshape(temp,1,4*length(temp));
% Calculate Bit Errors
diff = uncoded_bits - B_hat ;
T_Errors = T_Errors + sum(abs(diff));
T_bits = T_bits + length(uncoded_bits);
end
% Calculate Bit Error Rate
BER(aa) = T_Errors / T_bits;
disp(sprintf('bit error probability = %f',BER(aa)));
%
% Plot the received Symbol Constellation
figure(1);
subplot(2,2,1);
grid on;
plot(rx,'o');
xlabel(' Composant Inphase');
ylabel(' Composant Quadrature');
title(['effet du bruit sur le signal pour un SNR = ', num2str(SNR(aa))]);
axis([-2 2 -2 2]);
end
%the previously used variables and close all figures
% Frame Length
end |
Partager