Documente Academic
Documente Profesional
Documente Cultură
Exemplul 1.1
clear all
close all
N = 128;
s3 = s1(1:N);
s4 = s2(1:N);
s = s3+s4;
[b,a] = butter(12,1600/5000,'high');
y = filter(b,a,s);
figure
plot((0:(N-1))/N*fe, abs(fft(y))) %Fig. 4
figure
%varianta - spectrul centrat in origine:
plot((-N/2:N/2-1)/N*fe, abs(fftshift(fft(y)))) %Fig. 5
2
B. Semnale aleatorii discrete: reprezentri,
parametri statistici
%Exemplul 1.2
%Distributii de probabilitate; valori medii statistice
%Observatii:
%1."Zgomot alb" = semnal aleatoriu cu toate esantioanele complet
%necorelate; poate avea orice distributie de probabilitate.
%2. Prin definitie, un "semnal aleatoriu Gaussian" (cu distributie de
%probabilitate normala) este stationar in sens larg, are valoarea
%medie zero si varian sigma^2.
%3. "Zgomot alb Gaussian" (WGN - "White Gaussian Noise") = un semnal
%de tip zgomot alb, cu distributie Gaussiana (medie zero, varian
%sigma^2).
%4. functia Matlab randn() genereaza un "zgomot alb Gaussian standard"
%(mai exact, o secventa pseudoaleatorie), cu medie zero si varian 1.
close all
clear all
n = 0:100;
x1 = randn(size(n)); %help randn
x2 = randn(size(n));
%Comentariu - variante de scriere:
%x = randn(1,101);
%x = randn(1,length(n));
subplot(2,1,1)
stem(n,x1,'filled')
title('Doua secvente de tip zgomot alb Gaussian (WGN)')
subplot(2,1,2)
stem(n,x2,'filled') %Fig. 1
figure
hist(randn(1,10000),50) %help hist Fig. 2
title('Histograma unui WGN (10000 puncte)')
figure
n1 = 0:1000;
x11 = randn(1,1001);
x22 = randn(1,1001);
subplot(2,2,1)
3
stem(n1,x11,'filled')
subplot(2,2,2)
hist(x11,50)
subplot(2,2,3)
stem(n1,x22,'filled')
subplot(2,2,4)
hist(x22,50) %Fig. 3
figure
[h,x] = hist(randn(1,10000),50);
m = 0 ; sigma = 1;
p = (1/(sigma*sqrt(2*pi)))*exp(-((x-m).^2)/(2*sigma^2));
h1 = (h/max(h))/(sigma*sqrt(2*pi)); %pentru scalare
bar(x,h1,'b'), grid
hold on
plot(x,p,'r','linewidth',2) %Fig. 4
title('Distributie Gaussiana teoretica si histograma simulata pentru
un WGN')
hold off
x3 = 4 + 3*x1;
figure
subplot(2,1,1)
stem(n,x1,'filled')
subplot(2,1,2)
stem(n,x3,'filled') %Fig. 5
4
media_x1 = mean(x1) %help mean
var_x1 = var(x1) %help var
SD_x1 = std(x1) %help std
media_x2 = mean(x2)
var_x2 = var(x2)
SD_x2 = std(x2)
media_x3 = mean(x3)
var_x3 = var(x3)
SD_x3 = std(x3)
figure
x4 = rand(size(n)); %help rand
stem(n,x4,'filled') %Fig. 6
title('Zgomot alb cu distributie uniforma')
media_x4 = mean(x4)
var_x4 = var(x4)
SD_x4 = std(x4)
figure
hist(rand(1,10000),40) %Fig. 7
title('Histograma unui zgomot alb cu distributie uniforma (10000
puncte)')
5
%Exemplul 1.3
%Functiile de autocorelatie si intercorelatie; aplicatii
close all
clear all
figure
x3 = randn(1,200);
x4 = randn(1,200);
R_x3x4 = xcorr(x3,x4);
n3 = 0:398;
stem(n3,R_x3x4,'filled') %Fig. 3
%Se observa ca secventele x3 si x4 sunt practic necorelate!
6
fe = 8e3; Te = 1/fe; F1 = 300;
t_n = 0:Te:1;
s1 = sin(2*pi*F1*t_n);
s = s1(1:100);
figure
n = 0:99;
stem(n,s,'filled') %Fig. 4
figure
[C,lags3] = xcorr(s,'unbiased');
stem(lags3,C,'filled') %Fig. 5
%Interpretati graficul obtinut!
x = s+x1;
figure
R_xx = xcorr(x);
%versiune deplasata (nescalata)
stem(n1,R_xx,'filled') %Fig. 6
%Interpretati graficul obtinut!
figure
[D,lags4] = xcorr(x,'unbiased');
%versiune nedeplasata, centrata in origine
stem(lags4,D,'filled') %Fig. 7