malterlab作业题汇总_第1页
malterlab作业题汇总_第2页
malterlab作业题汇总_第3页
malterlab作业题汇总_第4页
malterlab作业题汇总_第5页
已阅读5页,还剩32页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、习题一2输入a=7 1 5;2 5 6;3 1 5,b=1 1 1; 2 2 2; 3 3 3,在命令窗口中执行下列表达式,掌握其含义: a(2,3)ans =6 a(:,2)ans = 1 5 1 a(3,:)ans =3 1 5 a(:,1:2:3)ans = 7 5 2 6 3 5 a(:,3).*b(:,2)ans = 5 12 15 a(:,3)*b(2,:)ans = 10 10 10 12 12 12 10 10 10 a*bans = 24 24 24 30 30 30 20 20 20 a.*bans = 7 1 5 4 10 12 9 3 15 a2ans = 66 17

2、66 42 33 70 38 13 46 a.2ans = 49 1 25 4 25 36 9 1 25 b/aans = 0.1842 0.2105 -0.2368 0.3684 0.4211 -0.4737 0.5526 0.6316 -0.7105 b./aans = 0.1429 1.0000 0.2000 1.0000 0.4000 0.33331.0000 3.0000 0.60003输入c=1:2:20,则c(i)表示什么?其中i=1,2,3,10; c=1:2:20c = 1 3 5 7 9 11 13 15 17 19 c(1)ans = 1 c(2)ans = 3 c(5)

3、ans = 9 c(10)ans = 194查找已创建变量的信息,删除无用的变量 whos a name size bytes class a 3x3 72 double arraygrand total is 9 elements using 72 bytes whos c name size bytes class c 1x10 80 double arraygrand total is 10 elements using 80 bytes clear a a? undefined function or variable a.5创建如下变量: 在03 均匀的产生10个点值,形成10维向量

4、 3*3阶单位距阵,随机距阵,魔方距阵,全0距阵,全1距阵, 生成以向量v=1,2,3,4为基础向量的范得蒙矩阵 生成3阶的希尔伯特矩阵 linspace(0,3,10)ans = 0 0.3333 0.6667 1.0000 1.3333 1.6667 2.0000 2.3333 2.6667 3.0000 e=ones(3,3)e = 1 1 1 1 1 1 1 1 1 randn(3,3)ans = -0.4326 0.2877 1.1892 -1.6656 -1.1465 -0.0376 0.1253 1.1909 0.3273 magic(3)ans = 8 1 6 3 5 7 4

5、9 2 eye(3,3)ans = 1 0 0 0 1 0 0 0 1 zeros(3,3)ans = 0 0 0 0 0 0 0 0 0 e=ones(3,3)e = 1 1 1 1 1 1 1 1 1randn(3,3)ans = -0.4326 0.2877 1.1892 -1.6656 -1.1465 -0.0376 0.1253 1.1909 0.3273e = 1 1 1 1 1 1 1 1 1ans = 1 1 1 1 8 4 2 1 27 9 3 1 64 16 4 1ans = 9 -36 30 -36 192 -180 30 -180 1806. (1)求方程组 的解r=5

6、 6 0 0 0;1 5 6 0 0;0 1 5 6 0;0 0 1 5 6;0 0 0 1 5,t=1 ;0 ;0 ;0; 1r = 5 6 0 0 0 1 5 6 0 0 0 1 5 6 0 0 0 1 5 6 0 0 0 1 5t = 1 0 0 0 1 rtans = 2.2662 -1.7218 1.0571 -0.5940 0.3188第八题ans = x*exp(x), log(sin(x) 1/(1+x2), x(3/2)第九题(1)y = -2.0946 1.0473 + 1.1359i 1.0473 - 1.1359i(2)x = -4 -1(3)p = 1 1 3(4)x

7、1 = .61375389080390682789737879102986 x2 = -.68619276878228013395848197030388 第十题ans = exp(-t)*sin(t) ans = c1*exp(-t)*sin(t)+c2*exp(-t)*cos(t)习题二1编写程序,计算1+3+5+7+(2n+1)的值(用input语句输入n 值)。解:程序:sum=0;n=input(please input a number:);t=2*n+1;for i=1:2:t sum=sum+i;enddisp(sum)结果:please input a number:4 25

8、2习题4-1 程序:x1=0:0.1:20;x2=-5:0.1:5;y1=sqrt(x1);y2=sin(x2);subplot(1,2,1)plot(x1,y1,.-r);subplot(1,2,2)plot(x2,y2,g);结果: 4-2. 使用for函数编写一个程序实现sum(a)的功能,其中a为矩阵。解:1. 程序:s=0;m=input(please input a number:);n=input(please input a number:);a=ones(m,n)for i=1:m for j=1:n s=s+a(i,j); endenddisp(s)2. 结果please

9、input a number:2please input a number:3a = 1 1 1 1 1 1 64-3. 编写一个函数文件,用于生成等比数列。1. 程序:q=1n=input(please input a number n:);m=input(please input a number m:);for j=1:(m-1) q=q*n;end disp(q) 结果:please input a number n:2please input a number m:5 164-7设 在四个子图中分别画出其曲线,并给出图例。程序:syms tt=0:pi/65:pi;x=cos(t);

10、subplot(2,2,1)plot(x,sin(2*t+0);title(a=0)subplot(2,2,2)plot(x,sin(2*t+pi/3);title(a=pi/3)subplot(2,2,3)plot(x,sin(2*t+pi/2);title(a=pi/2)subplot(2,2,4)plot(x,sin(2*t+pi);title(a=pi)结果:4-8. 绘制函数 的三维曲面图.程序x,y=meshgrid(-4*pi:0.1*pi:4*pi);r=sqrt(x.2+y.2);z=sin(r)./(r+eps);surf(x,y,z);结果 。49 程序 x=0:0.01

11、:2y1=sin(x);y2=0.5*exp(x);plot(x,y1,-.r,x,y2,g)legend(y=sin(x),y2=0.5*exp(x)xlabel(x);ylabel(y);结果习题三1.1 在matlab命令窗口输入 funtool,在弹出的figure no.3产生以下信号波形: 3sin(x),5exp(-x),sin(x)/x,1-2abs(x)/a, sqrt(a*x) (a=2)1.2 产生50hz的正弦波的程序 t=0:0.001:50; y=sin(2*pi*50*t); plot(t(1:50),y(1:50) title(sin)1.3 产生加入随机噪声的

12、正弦波: t=0:0001:50; y=sin(2*pi*50*t); s=y+randn(size(t);plot(t(1:50),s(1:50)1.4 产生周期方波的的程序:(f=30hz) t = 0:.0001:.0625; y = square(2*pi*30*t); plot(t,y)1.5 产生周期锯齿波 t=0:0.001:0.25; y=sawtooth(2*pi*30*t); plot(t,y) axis(0 0.2 -1 1)2. 试用matalb绘制两正弦序列 的时域波形,观察它们的周期性,并验证是否与理论分析结果相符。(提示:并非所有的离散时间正弦序列信号都是周期的,

13、不同于连续时间正弦信号)3. 完成与两函数的卷积运算其中:在一个图形窗口中,画出、以及卷积结果。4 已知描述某连续系统的微分方程为:,试用matlab:(1)绘出该系统在030s范围内,并以时间间隔0.01s取样的冲激响应和阶跃响应的时域波形;(2)求出系统在030s范围内,并以时间间隔0.01s取样的冲激响应和阶跃响应的数值解。h =2/21*exp(-1/4*t)*sin(3/4*7(1/2)*t)*7(1/2)*(-1+heaviside(t)g=-1/168*heaviside(t)*(-21+exp(-1/4*t)*sin(3/4*7(1/2)*t)*7(1/2)+21*exp(-1

14、/4*t)*cos(3/4*7(1/2)*t)5已知某一连续时间信号为,试绘出它的时域波形响应的频谱图。6. 绘制系统函数的零极点图;绘制系统的幅频特性和相频特性;求单位冲激响应h(t)并画图;用laplace逆变换求h(t)表达式,并分析系统的稳定性。h(s)=(s2+s)/(2s2+6s+4)f =1/2*dirac(t)-exp(-2*t) 7. 习题69 要求同习题68zeros = -2 -1poles = 0.0000 + 1.4142i 0.0000 - 1.4142i -2.0000 -1.0000 f =1/2*2(1/2)*sin(2(1/2)*t)8 习题610y1 =i

15、*(exp(-i*w)-1)/w/(1+i*w)2 y1 =(1-exp(-x)*x-exp(-x)*heaviside(x)+(exp(-x+1)*x-1)*heaviside(x-1) y2 =(1/s-exp(-s)/s)/(s+1)2 y2 =(-1+exp(-t+1)*t)*heaviside(t-1)+1-t*exp(-t)-exp(-t)习题四1. 产生下列序列:(1)产生周期为1 的方波t=0:0.01:5;x=square(2*pi*t);subplot(221)plot(t,x)%产生占空比为50% 的方波t=0:0.01:5;x=square(2*pi*t,50);sub

16、plot(222)plot(t,x) %产生占空比为80% 的方波 t=0:0.01:5;x=square(2*pi*t,80);subplot(223)plot(t,x) %产生占空比为20% 的方波t=0:0.01:5;x=square(2*pi*t,10);subplot(224)plot(t,x)(1) 产生正弦序列并画图程序如下:ts=0.01*pi;n=0:100;x=sin(2*pi*n*ts);stem(n,x)2 已知离散系统的系统函数为,绘出其零、极点分布图;求系统的频率响应和单位脉冲响应,试编程。零极点分布图:程序:b=1 0.8 0;a=1 1 0.25;zplane(

17、b,a);单位脉冲响应:程序:delta=1 zeros(1,63);b=1 0.8 0;a=1 1 0.25;h=impz(b,a,64);stem(h);频率响应程序:b=1 0.8 0;a=1 1 0.25;h f=freqz(b,a,256,1);hr=abs(h);hph=angle(h)*180/pi;subplot(2,1,1)plot(f,hr);xlabel(归一化频率)ylabel(幅度)title(幅频响应)subplot(2,1,2)plot(f,hph);xlabel(归一化频率)ylabel(相位/角度)title(相频响应):3 已知序列求两序列的卷积。程序:a=

18、1 2 3 4;b=1 1 1 2;x=conv(a,b)stem(x);title(线性卷积)结果:x = 1 3 6 11 11 10 8图示:3. 已知序列分别求两序列的dft。程序:a=1 2 3 4;b=1 1 1 2;y1=conv(b,a);subplot(2,1,1)stem(y1);x1=fft(a,7);x2=fft(b,7);x=x1.*x2;x=ifft(x)subplot(2,1,2)stem(x);title()结果:x = 1.0000 3.0000 6.0000 11.0000 11.0000 10.0000 8.0000图1234567051015123456

19、7051015?书75 程序:wp=80*2*pi;ws=60*2*pi;fs=200;rp=1;rs=40;n,ws=cheb1ord(wp,ws,rp,rs,s);待添加的隐藏文字内容2z p k=buttap(n)a b c d=zp2ss(z,p,k)b a=zp2tf(z,p,k)freqs(b,a)传递函数形式:b = 0 0 0 0 0 0 0 0 1.0000a =1.0000 5.1258 13.1371 21.8462 25.6884 21.8462 13.1371 5.1258 1.0000零极点增益形式:z = p = -0.1951 + 0.9808i -0.1951

20、 - 0.9808i -0.5556 + 0.8315i -0.5556 - 0.8315i -0.8315 + 0.5556i -0.8315 - 0.5556i -0.9808 + 0.1951i -0.9808 - 0.1951ik = 1.0000状态方程形式:a =-1.9616 -1.0000 0 0 0 0 0 01.0000 0 0 0 0 0 0 0 0 1.0000 -1.6629 -1.0000 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 1.0000 -1.1111 -1.0000 0 0 0 0 0 0 1.0000 0 0 0 0 0 0

21、0 0 1.0000 -0.3902 -1.0000 0 0 0 0 0 0 1.0000 0b = 1 0 0 0 0 0 0 0c = 0 0 0 0 0 0 0 1.0000d = 0书76 程序:wn=150,300/500;b,a=butter(10,wn);subplot(2,1,1)hn=impz(b,a,100);stem(hn)subplot(2,1,2)h,w=freqz(b,a);plot(w,abs(h) 书77程序:clear all;close allf=0:0.01:1m(1:41)=1;m(42:61)=0;m(62:71)=0.5;m(72:81)=0;m(8

22、2:101)=1; plot(f,m,k:);hold onn=38;b=fir2(n,f,m); h,f1=freqz(b);f1=f1./pi;plot(f1,abs(h);legend(理想滤波器,设计滤波器);xlabel(归一化频率),ylabel(幅值);习题五:8-1 程序:ts=1/64; %采样时间间隔t=2; %信号时长fm1=75; %信源信号频率fm2=100;fc=10000; %载波频率 t=0:ts:t-ts;mt=0.1*cos(2*pi*fm1*t)+0.3*sin(2*pi*fm2*t); %信源信号t_dsb=mt.*cos(2*pi*fc*t); %时域

23、调制信号delta_f=1/t; %频率分辨率n=length(t_dsb); %采样点数f=delta_f*-n/2:n/2-1; f_mt=fft(mt); f_mt=t/n*fftshift(f_mt); %把fft结果平移到负频率上 psf_mt=(abs(f_mt).2+eps)/t; %基带信号功率谱f_dsb=fft(t_dsb); %时域调制信号的fft f_dsb=t/n*fftshift(f_dsb); %把fft结果平移到负频率上psf_dsb=(abs(f_dsb).2+eps)/t; %时域调制信号的功率谱subplot(221);plot(t,mt);grid on

24、;xlabel(t);ylabel(amp);title(基带信号)subplot(222);plot(f,abs(f_mt);grid on;%plot(f,10*log10(psf_mt);xlabel(f);ylabel(psf);title(基带信号功率谱)subplot(223);plot(t,t_dsb);grid on; % t_dsb时域调制信号xlabel(t);ylabel(amp);title(dsb信号)subplot(224);plot(f,abs(f_dsb);grid on;%plot(f,10*log10(psf_dsb);xlabel(f);ylabel(ps

25、f);title(dsb信号功率谱)结果:8-2.程序:ts=1/128; %采样时间间隔t=2; %信号时长fc=20000; %载波频率 t=0:ts:t-ts;mt=1-abs(t-1); %信源信号t_dsb=mt.*cos(2*pi*fc*t); %时域调制信号delta_f=1/t; %频率分辨率n=length(t_dsb); %采样点数f=delta_f*-n/2:n/2-1; f_mt=fft(mt); f_mt=t/n*fftshift(f_mt); %把fft结果平移到负频率上psf_mt=(abs(f_mt).2+eps)/t; %基带信号功率谱f_dsb=fft(t_

26、dsb); %时域调制信号的fftf_dsb=t/n*fftshift(f_dsb); %把fft结果平移到负频率上psf_dsb=(abs(f_dsb).2+eps)/t; %时域调制信号的功率谱subplot(221);plot(t,mt);grid on;xlabel(t);ylabel(amp);title(基带信号)subplot(222);plot(f,abs(f_mt);grid on;%plot(f,10*log10(psf_mt);xlabel(f);ylabel(psf);title(基带信号功率谱)subplot(223);plot(t,t_dsb);grid on; % t_dsb时域调制信号xlabel(t);ylabel(amp);title(am信号)subplot(224);plot(f,abs(f_dsb);grid on;%plot(f,10*log10(psf_dsb);xlabel(f);ylabel(psf);title(am信号功率谱)结果:8-5程序:a=1; fc1=2;fc2=4;f

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论