clear; F0 = 6000; F1 = 2000; Fe = 48000; Te = 1/Fe; Ts = 1/300; Ns = floor(Ts/Te); % Question 3.1.1.1 %bits = randi([0, 1], 1, 300); load('DonneesBinome1.mat'); NRZ = repelem(bits, Ns); T = 0:Te:Ns*84000/Fe-Te; % Question 3.1.1.2 %plot(T, NRZ); %xlabel("temps (s)"); %ylabel("NRZ(t)"); % Question 3.1.1.3 %N_fft = 48000; %F = 0:1/N_fft:Fe; %perio = abs(fft(NRZ, N_fft)).^2/N_fft; %semilogy(perio); %periodogram(NRZ); % Question 3.1.2.1 phi = 2*pi*rand(2, 1); X = (1-NRZ).*cos(2*pi*F0*T + phi(1)) + NRZ.*cos(2*pi*F1*T + phi(2)); %plot(T, X); %xlabel("temps (s)"); %ylabel("X(t)"); % Question 3.1.2.4 %periodogram(X); % Question 3.2 N = Ns*84000; Px = mean(abs(X).^2); Pb = Px / 10^(10/10); sigma = sqrt(Pb); bruit = sigma*randn(1, N); Xb = X + bruit; %periodogram(Xb); %plot(Xb); %semilogy([0:N-1]/N*Fe, abs(fft(Xb, N))); %hold; % Question 3.3.1 : Passe-bas fc_tild = 4000/Fe; A = 1; ordre = 100; B = 2*fc_tild*sinc(2*fc_tild*[-ordre/2:1:ordre/2]); Xf = filter(B, A, Xb); %plot(Xf); %plot(abs(fft(B, N))); %plot([-ordre/2:1:ordre/2], B); %semilogy([0:N-1]/N*Fe, abs(fft(Xf, N))); %periodogram(Xf); %hold; % Question 3.3.2 : Passe-haut fc_tild = 4000/Fe; ordre = 100; B = -2*fc_tild*sinc(2*fc_tild*[-ordre/2:1:ordre/2]); A = 1; B(ordre/2+1) = 1 - 2*fc_tild; Xf = filter(B, A, [Xb zeros(1, ordre/2)]); Xf = Xf(ordre/2:length(Xf)); % Le filtre est une version tronquée de la réponse idéale %plot(abs(fft(B, N))); %plot(Xf); %semilogy([0:N-1]/N*Fe, abs(fft(Xf, N))); %periodogram(Xf); %plot(B); % Question 3.3.5 K = 70; recup = []; bits_recup = []; for i = 0:N/Ns-1 somme = sum( Xf( i*Ns+1 : (i+1)*Ns ).^2 ); recup = [recup, somme]; if somme >= K bits_recup = [bits_recup, 0]; else bits_recup = [bits_recup, 1]; end end bits - bits_recup; erreur = sum((bits - bits_recup).^2)/N*Ns %image pcode reconstitution_image; reconstitution_image(bits_recup); which reconstitution_image; %legend("Xb", "Xf");