数字信号处理实验答案讲述.doc
文本预览下载声明
实验clear all;
a=[1 2 3 4];
b=[3 4 5 6];
c=a+b;
d=a-b;
e=a.*b;
f=a./b;
g=a.^b;
n=1:4;
subplot(4,2,1);stem(n,a);
xlabel(n);xlim([0 5]);ylabel(A);
subplot(4,2,2);stem(n,b);
xlabel(n);xlim([0 5]);ylabel(B);
subplot(4,2,3);stem(n,c);
xlabel(n);xlim([0 5]);ylabel(C);
subplot(4,2,4);stem(n,d);
xlabel(n);xlim([0 5]);ylabel(D);
subplot(4,2,5);stem(n,e);
xlabel(n);xlim([0 5]);ylabel(E);
subplot(4,2,6);stem(n,f);
xlabel(n);xlim([0 5]);ylabel(F);
subplot(4,2,7);stem(n,g);
xlabel(n);xlim([0 5]);ylabel(G);
(2)用MATLAB实现下列序列:
a) x(n)=0.8n 0≤n≤15
b) x(n)=e(0.2+3j)n 0≤n≤15
c) x(n)=3cos(0.125πn+0.2π)+2sin(0.25πn+0.1π) 0≤n≤15
d) 将c)中的x(n)扩展为以16为周期的函数x16(n)=x(n+16),绘出四个周期。
e) 将c)中的x(n)扩展为以10为周期的函数x10(n)=x(n+10),绘出四个周期。
clear all;
N=0:15;
% a) x(n)=0.8n 0≤n≤15
xa=0.8.^N;
figure;subplot(2,1,1);stem(N,xa); xlabel(n);xlim([0 16]);ylabel(xa);
% b) x(n)=e(0.2+3j)n 0≤n≤15
xb=exp((0.2+3*j)*N);
subplot(2,1,2);stem(N,xb);
xlabel(n);xlim([0 16]);ylabel(xb);figure;
% c) x(n)=3cos(0.125πn+0.2π)+2sin(0.25πn+0.1π) 0≤n≤15
xc=3*cos(0.125*pi*N+0.2*pi)+2*sin(0.25*pi*N+0.1*pi);
subplot(3,1,1);stem(N,xc);xlabel(n);xlim([0 16]);ylabel(xc);
% d) 将c)中的x(n)扩展为以16为周期的函数x16(n)=x(n+16),绘出四个周期。
k=0:3;m=0;
for i=1:4
for j=1:16
m=m+1;
n(m)=N(j)+16*k(i);
x16(m)=3*cos(0.125*pi*n(m)+0.2*pi)+2*sin(0.25*pi*n(m)+0.1*pi);
end
end
subplot(3,1,2);stem(n,x16);xlabel(n);ylabel(x16);
% e) 将c)中的x(n)扩展为以10为周期的函数x10(n)=x(n+10),绘出四个周期。
for j=1:10
x10(j)=x16(j);
end
for i=1:3
for m=1:10
x10(i*10+m)=x10(m);
end
end
n=1:40;
subplot(3,1,3);stem(n,x10); xlabel(n);ylabel(x10);
(3)x(n)=[1,-1,3,5],产生并绘出下列序列的样本:
a) x1(n)=2x(n+2)-x(n-1)-2x(n)
b)
clear all
n=1:4;
T=4;
x=[1 -1 3 5];
x(5:8)=x(1:4);
subplot(2,1,1);stem(1:8,x);grid;
for i=1:4
if i-10
x1(i)=2*x(i+2)-x(i-1)-2*x(i);
else
x1(i)=2*x(i+2)-x(i-1+T)-2*x(i);
end
end
x1(5:8)=x1(1:4);
显示全部