资源描述:
《[信息与通信]matlab程序文本说明》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Matlab程序文本第一章离散时间信号与系统本程序产生均匀分布的白噪声信号set(gcf,'color','w');p=0.1;N=500000;u=rand(1,N);%用函数rand产生500000个随机数组u_mean1=mean(u(1:length(u)))power_u=var(u)subplot(211);plot(u(1:100));grid;%显示前100个随机数xlabel('n','fontSize',12);ylabel('u(n)','fontSize',12);title('(1)前100个随机数');subplot(212)hist(u,50);grid
2、;%画出随机数分布的直方图xlabel('n','fontSize',12);ylabel('u(n)','fontSize',12);title('(2)随机数分布的直方图');%u_mean=0.4997;power_u=0.0832%程序运行结果本程序产生零均值、方差为0.1且服从高斯分布的噪声信号set(gcf,'color','w')p=0.1;N=500000;u=randn(1,N);a=sqrt(p);%计算a值u=u*a;power_u=var(u);%把randn得到的噪声序列乘以a值。subplot(221);plot(u(1:100));gridxlabel(
3、'n','fontSize',12);ylabel('u(n)','fontSize',12);title('(1)白噪声序列');subplot(222)hist(u,50);grid%画出直方图xlabel('n','fontSize',12);ylabel('u(n)','fontSize',12);title('(2)白噪声序列的高斯分布');%power_u=0.0997mean_u=-8.9297e-004演示序列平移set(gcf,'color','w')x=[1,2,3,4,5,4,3,2,1];m=0:8subplot(221)H=stem(m,x);set(H,'
4、markersize',2);gridxlabel('n','FontSize',12);ylabel('x(n)','FontSize',12);title('(1)原序列');axis([0,15,0,6]);n0=4n=m+n0;y=xsubplot(222)H=stem(n,y);set(H,'markersize',2);gridxlabel('n','FontSize',12);ylabel('x(n+no)','FontSize',12);title('(2)平移序列');axis([0,15,0,6])演示函数conv在线性卷积中的用法set(gcf,'color',
5、'w');h=[4*ones(1,4),zeros(1,4)];nh=0:7;x=[1,4,3,1,zeros(1,5)];nx=-1:7;y=conv(x,h);n=-1:14;subplot(311);H=stem(nh,h);set(H,'markersize',6);grid;xlabel('n','FontSize',12);ylabel('h(n)','FontSize',12);title('(1)序列1');subplot(312);H=stem(nx,x);set(H,'markersize',6);grid;xlabel('n','FontSize',12);yl
6、abel('x(n)','FontSize',12);title('(2)序列2');subplot(313);H=stem(n,y);set(H,'markersize',6);grid;xlabel('n','FontSize',12);ylabel('y(n)','FontSize',12);title('(3)卷积所得的序列');y%y=420323632164000000000用Toeplitz矩阵计算线性卷积set(gcf,'color','w');x=[1,2,3]h=[3,4,5,6,7]%给定x和h向量Nx=length(x);Nh=length(h);L=Nx+N
7、h-1;%求向量长度%生成toeplitz矩阵H%TOEPLITZ(C,R)isanon-symmetricToeplitzmatrixhavingCasitsfirstcolumnandRasitsfirstrow.H=toeplitz([h(1),zeros(1,Nx-1)],[h,zeros(1,Nx-1)])y=x*H%用向量x左乘toeplitz矩阵,求出卷积subplot(2,2,1)Hd=stem(0:L-1,y);set(Hd,'marke