• 69.00 KB
  • 2022-04-22 11:49:58 发布

《MATLAB及在电子信息类课程中的应用》习题答案电子科大第二版.doc

  • 14页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
'第二章1、x=[2,4];y=x.^3+(x-0.98).^2./(x+1.35).^3-5*(x+1./x)2、y=cos(pi/3)-(9-sqrt(2))^(1/3)3、a=3;A=4;b=a.^2;B=b.^2-1;c=a+A-2*B;C=a+2*B+c4、x=[123;456;789]Desktop->Workspace,双击变量x5、clearx=magic(3)y=randn(3,3)xy=[x,y]yx=[x,y]z=xy(:,1:2)6、clearx=eye(4,4)y=triu(x)7、 clearx=rand(4,5)y=x([1,2],:)z=(y>=0.3).*y8、clearx=randn(5,5)y=inv(x)9、clearx=randn(5,5)z=x^510、clearA=[1,4,8;-3,6,-5;2,-7,-12];B=[5,4,3;6,-2,3;-1,3,-9];C=A*BD=A.*B11、clearx=linspace(0,2*pi,125);y=cos(x).*(0.5+3*sin(x)./(1+x.^2));plot(x,y) 12、z=-45:1:45;x=z.*sin(3*z);y=z.*cos(3*z);plot3(x,y,z);13、x=-2:0.1:2,y=x;[x,y]=meshgrid(x,y);z=x.^2.*exp(-x.^2-y.^2)surf(x,y,z);14、x=-2:0.1:2,y=x;[x,y]=meshgrid(x,y);z=x.^2.*exp(-x.^2-y.^2);surf(x,y,z);z1=0.05*x-0.05*y+0.1;holdon,mesh(x,y,z1);15、(1)n=2;alfa=0;t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);subplot(2,2,1);plot(t,x,t,y);(2)n=2;alfa=0;t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);subplot(2,2,1);plot(t,x,t,y);n=2;alfa=pi/3;t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);subplot(2,2,2);plot(t,x,t,y);n=2;alfa=pi/2;t=0:0.1:10;x=cos(t);y=sin(n*t+alfa); subplot(2,2,3);plot(t,x,t,y);n=2;alfa=pi;t=0:0.1:10;x=cos(t);y=sin(n*t+alfa);subplot(2,2,4);plot(t,x,t,y);球体clearfori=1:100forj=1:100x(i,j)=i/100*cos(j*2*pi/100);y(i,j)=i/100*sin(j*2*pi/100);z(i,j)=sqrt(1.001-x(i,j)^2-y(i,j)^2);endendsurf(x,y,z);holdon;surf(x,y,-z);axisequal棱锥clearfori=1:100forj=1:100x(i,j)=i/100*cos(j*2*pi/4);y(i,j)=i/100*sin(j*2*pi/4);z(i,j)=sqrt(x(i,j)^2+y(i,j)^2);endendsurf(x,y,-z);求最大值 x=[6787569943]max=0;fori=1:5ifmax>=x(i)max=max;elsemax=x(i)endendmax求最小值x=[6787569943]min=inf;fori=1:5ifmin<=x(i)min=min;elsemin=x(i)endendmin求和x=[6787569943];sum=0;fori=1:5sum=sum+x(i)endsum 第三章1、h0=[446,714,950,1422,1634];t0=[7.04,4.28,3.40,2.54,2.13];t1=interp1(h0,t0,500,"linear")2、x0=[1,0,-1];y0=[0,1,0];p=polyfit(x0,y0,3);x=-1:0.1:1;y=polyval(p,x);plot(x,y,-x,-y),axisequal3、clearx0=[1.0,1.1,1.2,1.3,1.4];y0=[0.25,0.2268,0.2066,0.1890,0.1736];p=polyfit(x0,y0,3);p1=polyder(p);y=polyval(p1,[1.0,1.2])4、p=[3472912];r=roots(p)5、r=[-3-5-8-9];p=poly(r) 6、functionypie=fun1(x,y)ypie=x.^2./y-x.*cos(y);[x,y]=ode45("fun1",[0,5],1)plot(x,y)7、functiony=fun2(x)y=x.^4-3*x^3+5*cos(x)+8;fplot("fun2",[1,5])holdon;x=0:5;y=0*x;plot(x,y)a=fzero(@fun2,2)b=fzero(@fun2,3)8、a=[249;424;9418];[v,gama]=eig(a)9、functionxpie=fun3(t,x)f=exp(-t)xpie=[0100;100-1;0001;0-1-10]*x+[0;1;0;0]*f[t,x]=ode45("fun3",[0,5],[0000]");plot(t,x(:,1),"b",t,x(:,3),"r") 10、functionf=fun4(x,y)f=4*(x-y)-x.^2-y.^2;v=-2:0.2:2;[x,y]=meshgrid(v)z=fun4(x,y);surf(x,y,z)求极小值(有误)functionf=fun5(x,y)x=v(1);y=v(2)f=-(4*(x-y)-x.^2-y.^2);v=-50:2:50;[x,y]=meshgrid(v)z=fun4(x,y);surf(x,y,z)min=fminsearch("fun4",[0,0])11、functionf=fun6(x,y)f=sin(y)+exp(x)-x.*y.^2ezplot("fun6")12、functionf=fun7(x,y)f=(x-y).^2.*(sin(x+y)).^2s=dblquad("fun7",pi,2*pi,0,pi) 14、a=randn(4,4)[l,u]=lu(a)a=randn(4,4)[u,gama,v]=svd(a)15、b=[30.54];a=[3456];[r,p,k]=residue(b,a)b=[30.54];a=[3456];[r,p,k]=residue(b,a)t=0:0.1:100;y=0*t;fori=1:3y=y+r(i)*exp(p(i)*t)endplot(t,y)b=[30.54];a=[3456];impulse(b,a)b=[30.54];a=[3456];step(b,a) 第四章1、n=1:11;x=cos(pi/6*n);subplot(2,1,1);stem(x);y=abs(fft(x));subplot(2,1,2);stem(y);clearn=0:11;x=cos(pi/6*n);subplot(2,1,1);stem(x);y=abs(fft(x));subplot(2,1,2);stem(y);2、(有误)n=0:19;x=5*0.6.^n;subplot(3,1,1);stem(n,x);fori=-20:39xl(i+21)=x(mod(i+40,20)+1);endn1=-20:39;subplot(3,1,2);stem(n1,x1);x2=x1(10:29);subplot(3,1,3);stem(n,x2)新方法m=10;e=0:19;c=0.6;k=5;a=k*c.^e;a=a"; b=circshift(a,m);L=length(a)-1;n=0:L;subplot(2,1,1);stem(n,a);axis([0,L,min(a),max(a)]);subplot(2,1,2);stem(n,b);axis([0,l,min(a),max(a)])3、x=[0.80.80.80.80.80.80.80.80.80.80.80.800000000];h=[11111100000000000000]y=conv(x,h);stem(y)4、x=[0.80.80.80.80.80.80.80.80.80.80.80.800000000];h=[11111100000000000000]y=conv(x,h);subplot(2,1,1);stem(y)xx=fft(x);hh=fft(h);yy=ifft(xx.*hh);subplot(2,1,2);stem(yy)5、b=[23];a=[10.41];[zpk]=tf2zp(b,a) 6、b=[415.662.4-6.4];a=[32.46.3-11.46];[zpk]=tf2zp(b,a)7、b=[18];a=[183-4-1];[rpk]=residue(b,a)8、b=[0.20.31];a=[10.41];freqs(b,a)9、Fs=2000;wc=[100200]/(Fs/2);N=10;[b,a]=butter(N,wc,"z");%freqz(b,a)dimpulse(b,a,100)10、wp=100;ws=200;rp=2;rs=15;Fs=500;wp=wp/(Fs/2);ws=ws/(Fs/2);[N,wc]=buttord(wp,ws,rp,rs);[b,a]=butter(N,wc,"z")freqz(b,a)11、b=fir1(48,[0.350.65]);a=1;freqz(b,a) 12、b=fir1(37,0.3);a=1;freqz(b,a)13、低通:F=[0:1/56:1];A=[ones(1,50),zeros(1,56-49)];b=fir2(56,F,A);a=1;freqz(b,a)带通:F=[0:1/56:1];A=[ones(1,25),zeros(1,25),ones(1,7)];b=fir2(56,F,A);a=1;freqz(b,a)高通F=[0:1/56:1];A=[zeros(1,50),ones(1,56-49)];b=fir2(56,F,A);a=1;freqz(b,a)%滤波器设计(椭圆滤波器)wp1=300;wp2=700;ws1=301;ws2=699;rp=0.1;rs=50;Fs=2000;wp=[wp1]/(Fs/2);ws=[ws1]/(Fs/2);[N,wc]=ellipord(wp,ws,rp,rs,"z")[b,a]=ellip(N,rp,rs,wc,"high")%滤波器特性分析 freqz(b,a)%信号采样及时频变换Fs=2000;t=0:1/Fs:10;yt=sin(2*pi*200*t)+sin(2*pi*500*t)+sin(2*pi*800*t);figure(2);subplot(3,1,1);plot(t,yt)figure(2);subplot(3,1,2);plot(t,yt);axis([0,0.1,-5,5])yf=abs(fft(yt));f=(1:length(yf))/length(yf)*Fs;figure(2);subplot(3,1,3);plot(f,yf)%信号滤波及时频分析yt1=filter(b,a,yt);figure(3);subplot(3,1,1);plot(t,yt1)figure(3);subplot(3,1,2);plot(t,yt1);axis([0,0.1,-5,5])yf1=abs(fft(yt1));f=(1:length(yf1))/length(yf1)*Fs;figure(3);subplot(3,1,3);plot(f,yf1)'