Documente Academic
Documente Profesional
Documente Cultură
17
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
8
Exemplul 1. Se consideră semnalul discret x n sin n . Să se determine
3
perioada fundamentală a acestui semnal. Programul următor generează și afişează
acest semnal pentru n 10 :10 .
na=-10:10;
xa=sin(pi*8/3*na);
figure(1);
clf;
stem(na,xa)
grid on
h=title('$x_a[n]=sin\Big(\pi\cdot \frac{8}{3}\cdot n\Big)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_a[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
18
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
și impar, dacă
x n x n . (11)
Orice semnal discret x n poate fi exprimat ca suma a două componente, una
pară și una impară. Componenta pară este
1
xe n
2
x n x n , (12)
iar componenta impară este
1
2
x n x n .
xo n (13)
Semnalul x n se numeşte semnalul x n reflectat sau oglindit, deoarece
reprezintă varianta în oglindă faţă de axa verticală a semnalului x n (vezi Secţiunea
2.1).
Semnalul discret va fi suma dintre cele două componente :
x n xe n xo n . (14)
n=-8:8
x=[zeros(1,7) 1/2 1 1 1 1/2 zeros(1,5)]
figure(1)
clf;
subplot(3,2,1)
stem(n,x)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[n]$');
set(h,'Interpreter','latex','Fontsize',16)
19
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
pause
subplot(3,2,3)
xrefl=fliplr(x);
stem(n,xrefl)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[-n]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
xe=0.5*(x+xrefl);
subplot(3,2,5)
stem(n,xe)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_e[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x_e[n]=0.5 \cdot (x[n]+x[-n])$');
set(h,'Interpreter','latex','Fontsize',16)
pause
subplot(3,2,2)
stem(n,x)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[n]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
subplot(3,2,4)
stem(n,xrefl)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
20
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[-n]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
xo=0.5*(x-xrefl);
subplot(3,2,6)
stem(n,xo)
axis([min(n)-0.2 max(n)+0.2 -1.2 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_o[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x_o[n]=0.5 \cdot (x[n]-x[-n])$');
set(h,'Interpreter','latex','Fontsize',16)
pause
21
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
O altă operație care se poate efectua asupra semnalului discret este reflectarea
lui. În acest caz, variabila independentă n se înlocuiește cu –n, operație numită
reflectare (sau oglindire) a semnalului în raport cu axa ordonatelor.
n ... -2 -1 0 1 2 3 4 5 6 7 ...
x n ... 0 1/2 1 1 1 1/2 0 0 0 0
x n 3 ... 0 0 0 0 1/2 1 1 1 1/2 0 ...
u n ... 0 0 1 1 1 1 1 1 1 1 ...
u 2 n ... 1 1 1 1 1 0 0 0 0 0 ...
x n 3 u 2 n ... 0 0 0 0 1/2 0 0 0 0 0 ...
x n 1 ... 0 0 1/2 1 1 1 1/2 0 0 0 ...
n ... 0 0 1 0 0 0 0 0 0 0 ...
n 2 ... 0 0 0 0 1 0 0 0 0 0 ...
x n 1 n 2 ... 0 0 0 0 1 0 0 0 0 0 ...
Figura 4. Semnalele x n 1 n 2 şi x n 3 u 2 n
22
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
figure(2)
clf
subplot(3,1,1)
stem(n,x)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title('Semnalul $x[n]$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
subplot(3,1,2)
stem(n,[zeros(1,2) x(1:15)])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title('Semnalul $x[n]$ deplasat la dreapta (intarziat) cu 2
esantioane');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n-2]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
subplot(3,1,3)
stem(n,[x(3:17) zeros(1,2)])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title('Semnalul $x[n]$ deplasat la stanga cu 2 esantioane');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n+2]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
figure(3)
clf
subplot(2,2,1)
stem(n,xrefl)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
23
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
pause
subplot(2,2,2)
stem(n,[zeros(1,4) xrefl(1:13)])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[4-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[4-n]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
subplot(2,2,3)
stem(n,[zeros(1,4) x(1:13)])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title({'Semnalul $x[n]$ deplasat la dreapta (intarziat)',
'cu 4 esantioane'});
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n-4]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
subplot(2,2,4)
stem(n,[xrefl(5:17) zeros(1,4)])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title({'Semnalul $x[-n-4]$'});
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[-n-4]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
figure(4)
clf
subplot(3,1,1)
24
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
stem(n,x)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title('Semnalul $x[n]$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
subplot(3,1,2)
u_de_2_minus_n=[ones(1,11) zeros(1,6)];
stem(n,u_de_2_minus_n,'r')
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$u[2-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $u[2-n]$');
set(h,'Interpreter','latex','Fontsize',16)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
pause
subplot(3,1,3)
stem(n,u_de_2_minus_n.*x)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n] \cdot u[2-n]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[n] \cdot u[2-n]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
figure(5)
clf
subplot(3,1,1)
stem(n,[x(2:17) 0])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
h=title('Semnalul $x[n+1]$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
25
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
hy=ylabel('$x[n+1]$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
subplot(3,1,2)
delta_de_n_minus_2=[zeros(1,10) 1 zeros(1,6)];
stem(n,delta_de_n_minus_2,'r')
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$\delta[n-2]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $\delta[n-2]$');
set(h,'Interpreter','latex','Fontsize',16)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
pause
subplot(3,1,3)
stem(n,delta_de_n_minus_2.*[x(2:17) 0])
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n+1] \cdot \delta[n-2]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[n+1] \cdot \delta[n-2]$');
set(h,'Interpreter','latex','Fontsize',16)
pause
figure(6)
clf
x_de_n_to_2=zeros(1,17);
for n_index=-8:8
if n_index^2<=4
x_de_n_to_2(n_index+9)=x(n_index^2+9);
end
end
stem(n,x_de_n_to_2)
axis([min(n)-0.2 max(n)+0.2 0 1.2])
grid on
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x[n^2]$');
set(hy,'Interpreter','latex','Fontsize',16)
h=title('Semnalul $x[n^2]$');
set(h,'Interpreter','latex','Fontsize',16)
26
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
3. Aplicații rezolvate
% Program P2_II_2_sin_F_320_minus_sin_F_640
clear;
clc;
t=(0:0.01:10)*1e-3;
xa=sin(640*pi*t)-sin(1280*pi*t);
figure(1);
clf;
plot(t*1e3,xa,'b')
axis([0 10 -2 3])
grid on
h=title('$x_a(t)=sin(640\cdot \pi\cdot t) - sin(1280\cdot
\pi\cdot t)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$t [ms]$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_a(t)$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
syms t w
X_a_w=fourier(sin(640*pi*t)-sin(1280*pi*t),t,w)
figure(2);
clf;
% stem([-1280*pi -640*pi 640*pi 1280*pi]/(2*pi),[-pi pi -pi
pi]/pi,'^m')
stem([-640*pi 1280*pi]/(2*pi),[pi pi]/pi,'^b','filled')
hold on
stem([-1280*pi 640*pi]/(2*pi),[-pi -pi]/pi,'vb','filled')
axis([-800 800 -2.2 2.2])
grid on
h=title('$Spectrul~ semnalului~ x_a(t)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$F [Hz]$');
27
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$\frac{Im\{X_a(F)\}}{\pi}$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
figure(3);
clf;
nd=-10:10;
xd1=sin(640*pi*nd/960)-sin(1280*pi*nd/960);
xd2=2*sin(2*pi/3*nd);
stem(nd,xd1,'ro','filled')
hold on
stem(nd,xd2,'gd');
axis([-10 10 -2.5 3])
grid on
hl=legend('$x_1[n]=sin\Big(640\cdot \pi\cdot
\frac{n}{960}\Big) - sin\Big(1280\cdot \pi\cdot
\frac{n}{960}\Big)$','$x_2[n]=2\cdot sin\Big(2\cdot \pi \cdot
\frac{1}{3}\cdot n\Big)$');
set(hl,'Interpreter','latex','Fontsize',14)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_1[n] (cu~ rosu), x_2[n] (cu~ verde)$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
t=(0:0.01:10)*1e-3;
xa=sin(640*pi*t)-sin(1280*pi*t);
xr=2*sin(2*pi/3*t*960);
figure(1);
clf;
plot(t*1e3,xa,'b',t*1e3,xr,'m')
axis([0 10 -2 3])
grid on
hl=legend('$x_a(t)$','$x_r(t)$');
set(hl,'Interpreter','latex','Fontsize',14)
h=title('$x_a(t)=sin(640\cdot \pi\cdot t) - sin(1280\cdot
\pi\cdot t), x_r(t)=2\cdot sin\Big(2\cdot \pi \cdot
\frac{1}{3}\cdot t\cdot 960\Big)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$t [ms]$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_a(t) (cu~ albastru), x_r(t) (cu~ magenta)$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
hold on
t=(0:1/960*1e3:10)*1e-3;
xd_a=sin(640*pi*t)-sin(1280*pi*t);
28
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
stem(t*1e3,xd_a,'r')
hl=legend('$x_a(t)$','$x_r(t)$','$x_a\Big(\frac{n}{960}\Big)
(n=0,1,...,9)$',1);
set(hl,'Interpreter','latex','Fontsize',14)
hy=ylabel('$x_a(t) (cu~ albastru), x_r(t) (cu~ magenta),
x_a\Big(\frac{n}{960}\Big) (cu~ rosu)$');
set(hy,'Interpreter','latex','Fontsize',16)
pause
syms t w
X_r_w=fourier(2*sin(2*pi/3*t*960),t,w)
figure(2);
hold on
stem(-640*pi/(2*pi),2*pi/pi,'^m')
hold on
stem(640*pi/(2*pi),-2*pi/pi,'vm')
axis([-800 800 -2.2 2.2])
grid on
h=title('$Spectrele~ semnalelor~ x_a(t)~ si~ x_r(t)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$F [Hz]$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$\frac{Im\{X_a(F)\}}{\pi},
\frac{Im\{X_r(F)\}}{\pi}$');
set(hy,'Interpreter','latex','Fontsize',16)
2. Să se determine dacă semnalele următoare sunt periodice și dacă sunt, care este
perioada fundamentală. Să se realizeze un program Matlab care să afișeze aceste
semnale. Verificaţi dacă semnalele sunt periodice şi pentru cele care sunt, determinaţi
perioada fundamentală.
a) x n sin 2n
2
2
b) x n sin n cos n 2 cos n
2 6 3 4
nb=-30:30;
xb=sin(2*nb+pi/2);
figure(1);
clf;
stem(nb,xb)
grid on
h=title('$x_b[n]=sin\Big(2\cdot n+\frac{\pi}{2}\Big)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_a[n]$');
set(hy,'Interpreter','latex','Fontsize',16)
29
PNS Lucrarea 2 (Partea a II-a) Proprietățile semnalelor discrete. Operații cu semnale discrete
pause
nc=-20:20;
xc=sin(pi*nc/2)+cos(pi*nc/6)-2*sin(2*pi*nc/3+pi/4);
figure(1);
clf;
stem(nc,xc)
grid on
h=title('$x_c[n]=sin\Big(\frac{\pi\cdot n}{2}\Big) +
cos\Big(\frac{\pi\cdot n}{6}\Big) - 2\cdot
sin\Big(\frac{2\cdot\pi\cdot n}{3}+\frac{\pi}{4}\Big)$');
set(h,'Interpreter','latex','Fontsize',16)
hx=xlabel('$n$');
set(hx,'Interpreter','latex','Fontsize',16)
hy=ylabel('$x_c[n]$')';
set(hy,'Interpreter','latex','Fontsize',16)
4. Aplicații propuse
Exerciţiul 3. Se dă semnalul:
n
1 , n 3: 1,
x n 3
1, n 0 : 3
Să se calculeze și să se reprezinte cu ajutorul unui program Matlab următoarele
semnale: x n , x n 4 , x n 4 , x n 4 , x n u 1 n , x 2 n n 3 ,
x n 2 , xe n , xo n .
30