您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > 中南民大信号与系统MATLAB实验总汇
实验一、MATLABMATLABMATLABMATLAB编程基础及典型实例一、实验目的(1)熟悉MATLAB软件平台的使用;(2)熟悉MATLAB编程方法及常用语句;(3)掌握MATLAB的可视化绘图技术;(4)结合《信号与系统》的特点,编程实现常用信号及其运算。示例一:在两个信号进行加、减、相乘运算时,参于运算的两个向量要有相同的维数,并且它们的时间变量范围要相同,即要对齐。编制一个函数型m文件,实现这个功能。functionfunctionfunctionfunction[f1_new,f2_new,n]=duiqi(f1,n1,f2,n2)[f1_new,f2_new,n]=duiqi(f1,n1,f2,n2)[f1_new,f2_new,n]=duiqi(f1,n1,f2,n2)[f1_new,f2_new,n]=duiqi(f1,n1,f2,n2)a=min(min(n1),min(n2));a=min(min(n1),min(n2));a=min(min(n1),min(n2));a=min(min(n1),min(n2));b=max(max(n1),max(n2));b=max(max(n1),max(n2));b=max(max(n1),max(n2));b=max(max(n1),max(n2));n=a:b;n=a:b;n=a:b;n=a:b;f1_new=zeros(1,length(n));f1_new=zeros(1,length(n));f1_new=zeros(1,length(n));f1_new=zeros(1,length(n));f2_new=zeros(1,length(n));f2_new=zeros(1,length(n));f2_new=zeros(1,length(n));f2_new=zeros(1,length(n));tem1=find((n=min(n1))&(n=max(n1))==1);tem1=find((n=min(n1))&(n=max(n1))==1);tem1=find((n=min(n1))&(n=max(n1))==1);tem1=find((n=min(n1))&(n=max(n1))==1);f1_new(tem1)=f1;f1_new(tem1)=f1;f1_new(tem1)=f1;f1_new(tem1)=f1;tem2=find((n=min(n2))&(n=max(n2))==1);tem2=find((n=min(n2))&(n=max(n2))==1);tem2=find((n=min(n2))&(n=max(n2))==1);tem2=find((n=min(n2))&(n=max(n2))==1);f2_new(tem2)=f2;f2_new(tem2)=f2;f2_new(tem2)=f2;f2_new(tem2)=f2;四、实验内容与步骤(2)绘制信号x(t)=)32sin(2tet−的曲线,t的范围在0~30s,取样时间间隔为0.1s。t=0:0.1:30;t=0:0.1:30;t=0:0.1:30;t=0:0.1:30;y=exp(-sqrt(2)*t).*sin(2*t/3);y=exp(-sqrt(2)*t).*sin(2*t/3);y=exp(-sqrt(2)*t).*sin(2*t/3);y=exp(-sqrt(2)*t).*sin(2*t/3);plot(t,y);plot(t,y);plot(t,y);plot(t,y);(3)在n=[-10:10]范围产生离散序列:⎩⎨⎧≤≤−=Othernnnx,033,2)(,并绘图。n=-10:1:10;n=-10:1:10;n=-10:1:10;n=-10:1:10;z1=((n+3)=0);z1=((n+3)=0);z1=((n+3)=0);z1=((n+3)=0);z2=((n-3)=0);z2=((n-3)=0);z2=((n-3)=0);z2=((n-3)=0);x=2*n.*(z1-z2);x=2*n.*(z1-z2);x=2*n.*(z1-z2);x=2*n.*(z1-z2);stem(n,x);stem(n,x);stem(n,x);stem(n,x);(4)编程实现如下图所示的波形。t=-2:0.001:3;t=-2:0.001:3;t=-2:0.001:3;t=-2:0.001:3;f1=((t=-1)&(t=1));f1=((t=-1)&(t=1));f1=((t=-1)&(t=1));f1=((t=-1)&(t=1));f2=((t=-1)&(t=2));f2=((t=-1)&(t=2));f2=((t=-1)&(t=2));f2=((t=-1)&(t=2));f=f1+f2;f=f1+f2;f=f1+f2;f=f1+f2;plot(t,f);plot(t,f);plot(t,f);plot(t,f);axis([-2,3,0,3]);axis([-2,3,0,3]);axis([-2,3,0,3]);axis([-2,3,0,3]);(5)设序列f1(k)={0,1,2,3,4,5},f2(k)={6,5,4,3,2,1,0}。↓↓k=0k=0利用duiqi.m函数,求add_f(k)=f1(k)-f2(k),pro_f(k)=f1(k)×f2(k),并以子图形式画出f1(k)、f2(k)、add_f(k)、pro_f(k)。f1=0:5;f1=0:5;f1=0:5;f1=0:5;f2=6:-1:0;f2=6:-1:0;f2=6:-1:0;f2=6:-1:0;n1=-1:4;n1=-1:4;n1=-1:4;n1=-1:4;n2=-5:1;n2=-5:1;n2=-5:1;n2=-5:1;[f1_new,f2_new,n]=duiqi[f1_new,f2_new,n]=duiqi[f1_new,f2_new,n]=duiqi[f1_new,f2_new,n]=duiqi(f1,n1,f2,n2);(f1,n1,f2,n2);(f1,n1,f2,n2);(f1,n1,f2,n2);add_f=f1_new+f2_new;add_f=f1_new+f2_new;add_f=f1_new+f2_new;add_f=f1_new+f2_new;pro_f=f1_new.*f2_new;pro_f=f1_new.*f2_new;pro_f=f1_new.*f2_new;pro_f=f1_new.*f2_new;subplot(2,2,1)subplot(2,2,1)subplot(2,2,1)subplot(2,2,1)stem(n1,f1);stem(n1,f1);stem(n1,f1);stem(n1,f1);xlabel('n1');xlabel('n1');xlabel('n1');xlabel('n1');ylabel('f1');ylabel('f1');ylabel('f1');ylabel('f1');gridgridgridgridon;on;on;on;subplot(2,2,2)subplot(2,2,2)subplot(2,2,2)subplot(2,2,2)stem(n2,f2);stem(n2,f2);stem(n2,f2);stem(n2,f2);xlabel('n2');xlabel('n2');xlabel('n2');xlabel('n2');ylabel('f2');ylabel('f2');ylabel('f2');ylabel('f2');gridgridgridgridon;on;on;on;subplot(2,2,3)subplot(2,2,3)subplot(2,2,3)subplot(2,2,3)stem(n,add_f);stem(n,add_f);stem(n,add_f);stem(n,add_f);xlabel('n');xlabel('n');xlabel('n');xlabel('n');ylabel('add-f(k)');ylabel('add-f(k)');ylabel('add-f(k)');ylabel('add-f(k)');gridgridgridgridon;on;on;on;subplot(2,2,4)subplot(2,2,4)subplot(2,2,4)subplot(2,2,4)stem(n,pro_f);stem(n,pro_f);stem(n,pro_f);stem(n,pro_f);xlabel('n');xlabel('n');xlabel('n');xlabel('n');ylabel('pro-f(k)');gridylabel('pro-f(k)');gridylabel('pro-f(k)');gridylabel('pro-f(k)');gridon;on;on;on;五、实验报告要求(1)再调用某一函数文件时,该文件中除了输入、输出变量外的其它变量在调用函数结束后是否还存在?这些变量是全局还是局部变量?答:不存在,是局部变量。(2)设n=-10:0.2:20,你可以通过那些方法查看向量n的维数?经过关系运算y=(n=3)以后,y的维数是多少?y又等于什么?答:Length()函数或Workspace中的变量类型。维度不变,(3)通过MATLAB的帮助系统,学习fliplr函数的功能和使用方法。在此基础上,写出能够产生如下图形的程序,其中x(n)=44,2≤≤−nn。n=-4:4;n=-4:4;n=-4:4;n=-4:4;x1=2.^n;x1=2.^n;x1=2.^n;x1=2.^n;figure(1);figure(1);figure(1);figure(1);stem(n,x1);stem(n,x1);stem(n,x1);stem(n,x1);x2=fliplr(x1);x2=fliplr(x1);x2=fliplr(x1);x2=fliplr(x1);figure(2);figure(2);figure(2);figure(2);stem(n,x2);stem(n,x2);stem(n,x2);stem(n,x2);实验二、连续时间系统的时域分析一、实验目的(1)深刻理解卷积运算,掌握离散线性卷积、连续线性卷积的计算方法;(2)加深对线性时不变系统中零状态响应概念的理解,掌握其求解方法;(3)掌握给定连续系统的冲击响应和阶跃响应。实例2222:利用convconvconvconv函数,编制一个函数文件dconvdconvdconvdconv,其输出为两个序列卷积后的新序列以及与新序列对应的时间变量function[f,k]=dconv(f1,f2,k1,k2)function[f,k]=dconv(f1,f2,k1,k2)function[f,k]=dconv(f1,f2,k1,k2)function[f,k]=dconv(f1,f2,k1,k2)f=conv(f1,f2);f=conv(f1,f2);f=conv(f1,f2);f=conv(f1,f2);k_start=k1(1)+k2(1);k_start=k1(1)+k2(1);k_start=k1(1)+k2(1);k_start=k1(1)+k2(1);k_end=length(f1)+length(f2)-2;k_end=length(f1)+length(f2)-2;k_end=length(f1)+length(f2)-2;k_end=length(f1)+length(f2)-2;k=k_start:(k_start+k_end);k=k_start:(k_start+k_end);k=k_start:(k_start+k_end);k=k_start:(k_start+k_end
本文标题:中南民大信号与系统MATLAB实验总汇
链接地址:https://www.777doc.com/doc-5495192 .html