60 lines
1.3 KiB
Mathematica
60 lines
1.3 KiB
Mathematica
|
clear;
|
||
|
close all;
|
||
|
|
||
|
Fe = 24000;
|
||
|
Te = 1/Fe;
|
||
|
|
||
|
Rb = 6000;
|
||
|
M = 2^1;
|
||
|
Ts = log2(M)/Rb;
|
||
|
Ns = floor(Ts/Te);
|
||
|
|
||
|
N = 20;
|
||
|
bits = randi([0, 1], 1, N);
|
||
|
|
||
|
T = (0:N*Ns/log2(M)-1) * Te;
|
||
|
|
||
|
|
||
|
|
||
|
X_m = 2 * bits - 1; % mapping
|
||
|
X_k = kron(X_m, [1 zeros(1, Ns-1)]); % Suréchantillonnage
|
||
|
h = rcosdesign(0.5, 8, Ns); % réponse impulsionnelle en racine de cosinus surélevé.
|
||
|
X_f = filter(h, 1, X_k); % produit de convolution (filtrage)
|
||
|
|
||
|
figure;
|
||
|
plot(T, X_f);
|
||
|
title("Signal transmis via le modulateur 4");
|
||
|
xlabel("Secondes (s)");
|
||
|
ylabel("Amplitude");
|
||
|
%ylim([ -1.1 1.1 ]);
|
||
|
|
||
|
|
||
|
|
||
|
F = linspace(0, Fe/2, N);
|
||
|
|
||
|
alpha = 0.5;
|
||
|
sigma = 1;
|
||
|
|
||
|
indices = abs(F) < (1-alpha)/2/Ts;
|
||
|
DSP_theorique = indices(indices);
|
||
|
indices = (1-alpha)/2/Ts < abs(F) & abs(F) < (1+alpha)/2/Ts;
|
||
|
DSP_theorique = [ DSP_theorique, indices(indices) .* (1 + cos( pi*Ts/alpha .* ( abs(F(indices)) - (1-alpha)/2/Ts ) ))/2 ];
|
||
|
DSP_theorique = [ DSP_theorique, zeros(1, N-length(DSP_theorique)) ];
|
||
|
DSP_theorique = DSP_theorique*sigma;
|
||
|
|
||
|
DSP_numerique = pwelch(X_f);
|
||
|
F_num = linspace(0, Fe/2, length(DSP_numerique));
|
||
|
|
||
|
figure;
|
||
|
plot(F_num, DSP_numerique/max(smoothdata(DSP_numerique)));
|
||
|
hold;
|
||
|
plot(F, DSP_theorique);
|
||
|
|
||
|
title("DSP du signal transmis via le modulateur 4 et son équivalent théorique");
|
||
|
xlabel("Fréquence (Hz)");
|
||
|
ylabel("Amplitude");
|
||
|
%ylim([ 0 1 ]);
|
||
|
|
||
|
legend("DSP numérique", "DSP théorique");
|
||
|
|