数字信号处理Matlab练习.docx
《数字信号处理Matlab练习.docx》由会员分享,可在线阅读,更多相关《数字信号处理Matlab练习.docx(11页珍藏版)》请在冰豆网上搜索。
![数字信号处理Matlab练习.docx](https://file1.bdocx.com/fileroot1/2023-7/19/27194f5c-ed1d-43bf-9fd6-6220156b8b4d/27194f5c-ed1d-43bf-9fd6-6220156b8b4d1.gif)
数字信号处理Matlab练习
数字信号处理Matlab练习第1章
1、序列x[n]、y[n]、z[n]
x[n]={3-201452},
y[n]={071-349-2},
w[n]={-5436-501},
(1)x[n]序列
(2)y[n]序列
(3)w[n]序列
2.求序列x[n]={3-201452}的自相关序列
>>x=[3-201452]
x=
3-201452
>>y=[3-201452]
y=
3-201452
>>n1=length(y)-1;n2=length(x)-1;
r=conv(x,fliplr(y));计算两矩阵的卷积
k=(-n1):
n2';定义时间变量
stem(k,r);绘制二维离散时间信号
xlabel('Lagindex');ylabel('Amplitude');
v=axis;
axis([-n1n2v(3:
end)]);矩阵计算范围
>>m=xcorr(x,y)求两矩阵互相关系数
3.求序列y[n]={071-349-2}的自相关序列(方法同上)
4.求序列w[n]={-5436-501}的自相关序列(方法同上)
5.求序列x[n]与y[n]的互相关序列
>>x=[3-201452]
x=
3-201452
>>y=[071-349-2]
y=
071-349-2
m=
Columns1through7
-6.000031.0000-6.0000-19.000010.000049.000040.0000
Columns8through13
27.00004.000027.000037.000014.00000.0000
6.求序列x[n]与w[n]的互相关序列
m=
Columns1through7
3.0000-2.0000-15.000029.00001.00006.0000-35.0000
Columns8through13
12.000036.000038.00006.0000-17.0000-10.0000
7.画出序列x1[n]和x2[n],序列的序号n和参数M自己选择
(a)x1[n]=cos(πn/M),其中M为正整数;
(b)x2[n]=(-1)n。
1.X1[n]图
2.X2[n]图
n=linspace(-10,0.01,10);
stem((-1).^n,'fill','-.');
8.求x1[n]的自相关序列
n=(-10:
10);%指定n的范围
t=cos(n*pi);%x1[n]序列
[a,b]=xcorr(t,'n')%求得x1[n]自相关赋值给a,相关运算后得n赋给b
stem(b,a);%以a为纵坐标,b为横坐标画图
xlabel('Lagindex');ylabel('Amplitude');
a=
1.0000-2.00003.0000-4.00005.0000-6.00007.0000
-8.00009.0000-10.000011.0000-12.000013.0000-14.0000
15.0000-16.000017.0000-18.000019.0000-20.000021.0000
-20.000019.0000-18.000017.0000-16.000015.0000-14.0000
13.0000-12.000011.0000-10.00009.0000-8.00007.0000
-6.00005.0000-4.00003.0000-2.00001.0000
b=
-20-19-18-17-16-15-14-13-12-11-10-9
-8-7-6-5-4-3-2-10123
456789101112131415
1617181920
9.求x2[n]的自相关序列
9.利用Matlab函数rand产生一个均匀分布的随机信号,并加到序列x1[n]和x2[n]上,画出受到干扰的序列y1[n]=x1[n]+w1[n]和y2[n]=x2[n]+w2[n],其中w1[n]和w2[n]为随机信号;
(1.)序列y1[n]=x1[n]+w1[n]
n=(-8:
8);%指定n的范围
a=rand(1,17)%产生随机的序列
t=cos(n*pi);
y=(a+t)%将两序列相加
stem(n,y,'filled');
holdon;%保留y的图像一面被后面的图像覆盖
[b,c]=xcorr(y,'n')%求自相关
stem(c,b);
xlabel('Lagindex');ylabel('Amplitude');
产生随机数
a=0.91570.79220.95950.65570.03570.84910.9340
0.67870.75770.74310.39220.65550.17120.7060
0.03180.27690.0462
y=y1[n]=x1[n]+w1[n]
1.9157-0.20781.9595-0.34431.0357-0.15091.9340
-0.32131.7577-0.25691.3922-0.34451.1712-0.2940
1.0318-0.72311.0462
求自相关
b=2.0042-1.60264.1769-2.55465.6591-2.74138.3359
-4.054311.5915-4.936514.6138-5.593015.6233-6.2037
18.2083-7.312921.9631-7.312918.2083-6.203715.6233
-5.593014.6138-4.936511.5915-4.05438.3359-2.7413
5.6591-2.55464.1769-1.60262.0042
c=-16-15-14-13-12-11-10-9-8-7-6-5
-4-3-2-101234567
8910111213141516
(2.)序列y2[n]=x2[n]+w2[n]
产生随机数
a=
0.67970.65510.16260.11900.49840.95970.3404
0.58530.22380.75130.25510.50600.69910.8909
0.95930.54720.1386
y=x2[n]+w2[n]
1.6797-0.34491.1626-0.88101.4984-0.04031.3404
-0.41471.2238-0.24871.2551-0.49401.6991-0.1091
1.9593-0.45281.1386
求自相关
b=
1.9126-1.15334.7710-2.38867.2744-3.99318.8302
-4.243410.7936-5.118412.1991-5.632014.9092-7.7746
17.2574-8.380320.9015-8.380317.2574-7.774614.9092
-5.632012.1991-5.118410.7936-4.24348.8302-3.9931
7.2744-2.38864.7710-1.15331.9126
c=
-16-15-14-13-12-11-10-9-8-7-6-5
-4-3-2-101234567
8910111213141516