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
| function [mat_emis,nb_users,D,THCod,delta]=main_recepteur()
fc = 50e9;
[nb_bit,mat_emis,nb_users,D,THCod,delta]=emetteur_multi_trajet_802_15_4a_asy();
template = test_template(nb_users,D,THCod);
[output_sig]=main_channel();
for k=1:nb_users
figure(k)
plot(template(k,:));
title('template')
end
figure()
plot(mat_emis(1,:));grid on;
%hold on
%plot(mat_emis(2,:),'r');
title('sig emis');
figure()
plot(output_sig(1,:));grid on;
%hold on
%plot(mat_emis(2,:),'r');
title('sig emis bruité ');
for j=1:nb_users
s=mat_emis(j,:);
tmp=template(j,:);
for k=1:length(s)
C(:,k)=sum(s(k).*tmp);
end
figure();
plot(C,'r');
title('C');
C1(j,:)=C;
end
C1;
for j=1:nb_users
figure();
subplot(2,1,1);
plot(mat_emis(j,:));grid on;
title('mat_emis THCod=[1 0 2 1;0 1 3 2]et D=[1 0;0 1]');
subplot(2,1,2);
plot(C1(j,:));grid on;
title('correlation')
end
%%%%%%%%%%%ber%%%%%%%%%%%%%%
for j=1:nb_users
figure();
msg=output_sig(j,:);
msg_emis=mat_emis(j,:);
C2=C1(j,:);
for k=1:length(C2)
Bits=[msg,C2(k)>=0];
end
subplot(2,1,1);
plot(Bits);grid on;
title('bits THCod=[1 0 2 1;0 1 3 2]et D=[1 0;0 1]');
subplot(2,1,2);
plot(mat_emis);grid on;
title('mat_emis THCod=[1 0 2 1;0 1 3 2]et D=[1 0;0 1]');
Bits(j,:)=Bits;
end
Bits;
buffer=Bits;
siz_Bits=size(Bits);
siz_Corr=size(C1);
siz_buffer=size(buffer);
%%%%%%%%%%%%%%%%%%%%%%ù
fid = fopen('size_vector.txt','w');
%écrit dans ce fichier, fid est sa reference pour matlab
fprintf(fid,'%s\n','size(Bits);');
fprintf(fid,'%i\t %i\t %i\n',siz_Bits);
fprintf(fid,'%s\n','size(buffer) ');
fprintf(fid,'%i\t %i\t %i\n',siz_buffer);
fprintf(fid,'%s\n','siz_Corr ');
fprintf(fid,'%i\t %i\t %i\n',siz_Corr);
%n'oublie pas de fermer le fichier sinon tu ,ne peux pas le lire
fclose(fid);
ber=0;
for j=1:length(10)
bit=Bits(1,:);
msg=mat_emis(1,:);
if(msg(j)~=bit(j))
ber=ber+1;
end
end
ber=ber/length(Bits)
% ber=0;
% for j=1:length(mat_emis)
% bit=Bits(1,:);
% msg=mat_emis(1,:);
% if(msg(j)~=bit(j))
% ber=ber+1;
% end
% end
% ber=ber/length(Bits)
%%%%%%%%%%%%%%plot de ber%%%%%%%%
plot_BER_variation=[1.249219e-001 1.249609e-001 1.249777e-001 1.249826e-001 1.249880e-001 1.249896e-001 1.249913e-001];
figure()
plot(plot_BER_variation)
title('plot_BER_variation');
plot_BER_variation_user=[1.249479e-001 1.249609e-001 1.249740e-001 1.249740e-001 1.249740e-001 1.249740e-001 1.249826e-001 1.249870e-001 1.249888e-001];
figure()
plot(plot_BER_variation_user)
title('plot_BER_variation_user');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid = fopen('calcul_BER.txt','w');
%écrit dans ce fichier, fid est sa reference pour matlab
fprintf(fid,'%s\n','vecteur BER');
fprintf(fid,'%i\t %i\t %i\n',ber);
%n'oublie pas de fermer le fichier sinon tu ,ne peux pas le lire
fclose(fid); |
Partager