MATLAB与在电子信息类课程中的应用复习题答案电子科大第二版Word文档格式.docx
《MATLAB与在电子信息类课程中的应用复习题答案电子科大第二版Word文档格式.docx》由会员分享,可在线阅读,更多相关《MATLAB与在电子信息类课程中的应用复习题答案电子科大第二版Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。
y=x([1,2],:
)
z=(y>
=0.3).*y
8、
x=randn(5,5)
y=inv(x)
9、
z=x^5
10、
A=[1,4,8;
-3,6,-5;
2,-7,-12];
B=[5,4,3;
6,-2,3;
-1,3,-9];
C=A*B
D=A.*B
11、
x=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、
z=x.^2.*exp(-x.^2-y.^2);
z1=0.05*x-0.05*y+0.1;
holdon,mesh(x,y,z1);
15、
(1)
n=2;
alfa=0;
t=0:
10;
x=cos(t);
y=sin(n*t+alfa);
subplot(2,2,1);
plot(t,x,t,y);
(2)
alfa=pi/3;
subplot(2,2,2);
alfa=pi/2;
subplot(2,2,3);
alfa=pi;
subplot(2,2,4);
球体
fori=1:
100
forj=1:
x(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);
end
end
holdon;
surf(x,y,-z);
axisequal
棱锥
x(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);
求最大值
x=[6787569943]
max=0;
5
ifmax>
=x(i)
max=max;
elsemax=x(i)
max
求最小值
min=inf;
ifmin<
min=min;
elsemin=x(i)
min
求和
x=[6787569943];
sum=0;
sum=sum+x(i)
sum
第三章
h0=[446,714,950,1422,1634];
t0=[7.04,4.28,3.40,2.54,2.13];
t1=interp1(h0,t0,500,'
linear'
x0=[1,0,-1];
y0=[0,1,0];
p=polyfit(x0,y0,3);
x=-1:
1;
y=polyval(p,x);
plot(x,y,-x,-y),axisequal
x0=[1.0,1.1,1.2,1.3,1.4];
y0=[0.25,0.2268,0.2066,0.1890,0.1736];
p1=polyder(p);
y=polyval(p1,[1.0,1.2])
4、
p=[3472912];
r=roots(p)
r=[-3-5-8-9];
p=poly(r)
functionypie=fun1(x,y)
ypie=x.^2./y-x.*cos(y);
[x,y]=ode45('
fun1'
[0,5],1)
functiony=fun2(x)
y=x.^4-3*x^3+5*cos(x)+8;
fplot('
fun2'
[1,5])
x=0:
5;
y=0*x;
a=fzero(fun2,2)
b=fzero(fun2,3)
a=[249;
424;
9418];
[v,gama]=eig(a)
functionxpie=fun3(t,x)
f=exp(-t)
xpie=[0100;
100-1;
0001;
0-1-10]*x+[0;
0;
0]*f
[t,x]=ode45('
fun3'
[0,5],[0000]'
);
plot(t,x(:
1),'
b'
t,x(:
3),'
r'
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;
min=fminsearch('
fun4'
[0,0])
functionf=fun6(x,y)
f=sin(y)+exp(x)-x.*y.^2
ezplot('
fun6'
functionf=fun7(x,y)
f=(x-y).^2.*(sin(x+y)).^2
s=dblquad('
fun7'
pi,2*pi,0,pi)
a=randn(4,4)
[l,u]=lu(a)
[u,gama,v]=svd(a)
b=[30.54];
a=[3456];
[r,p,k]=residue(b,a)
100;
y=0*t;
3
y=y+r(i)*exp(p(i)*t)
plot(t,y)
impulse(b,a)
step(b,a)
第四章
n=1:
11;
x=cos(pi/6*n);
subplot(2,1,1);
stem(x);
y=abs(fft(x));
subplot(2,1,2);
stem(y);
n=0:
2、(有误)
19;
x=5*0.6.^n;
subplot(3,1,1);
stem(n,x);
fori=-20:
39
xl(i+21)=x(mod(i+40,20)+1);
n1=-20:
39;
subplot(3,1,2);
stem(n1,x1);
x2=x1(10:
29);
subplot(3,1,3);
stem(n,x2)
新方法
m=10;
e=0:
c=0.6;
k=5;
a=k*c.^e;
a=a'
;
b=circshift(a,m);
L=length(a)-1;
L;
stem(n,a);
axis([0,L,min(a),max(a)]);
stem(n,b);
axis([0,l,min(a),max(a)])
x=[0.80.80.80.80.80.80.80.80.80.80.80.800000000];
h=[11111100000000000000]
y=conv(x,h);
stem(y)
xx=fft(x);
hh=fft(h);
yy=ifft(xx.*hh);
stem(yy)
b=[23];
a=[10.41];
[zpk]=tf2zp(b,a)
b=[415.662.4-6.4];
a=[32.46.3-11.46];
b=[18];
a=[183-4-1];
[rpk]=residue(b,a)
b=[0.20.31];
freqs(b,a)
Fs=2000;
wc=[100200]/(Fs/2);
N=10;
[b,a]=butter(N,wc,'
z'
%freqz(b,a)
dimpulse(b,a,100)
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);
freqz(b,a)
b=fir1(48,[0.350.65]);
a=1;
b=fir1(37,0.3);
低通:
F=[0:
1/56:
1];
A=[ones(1,50),zeros(1,56-49)];
b=fir2(56,F,A);
带通:
A=[ones(1,25),zeros(1,25),ones(1,7)];
高通
A=[zeros(1,50),ones(1,56-49)];
%滤波器设计(椭圆滤波器)
wp1=300;
wp2=700;
ws1=301;
ws2=699;
rp=0.1;
rs=50;
wp=[wp1]/(Fs/2);
ws=[ws1]/(Fs/2);
[N,wc]=ellipord(wp,ws,rp,rs,'
[b,a]=ellip(N,rp,rs,wc,'
high'
%滤波器特性分析
%信号采样及时频变换
1/Fs:
yt=sin(2*pi*200*t)+sin(2*pi*500*t)+sin(2*pi*800*t);
figure
(2);
plot(t,yt)
plot(t,yt);
axis([0,0.1,-5,5])
yf=abs(fft(yt));
f=(1:
length(yf))/length(yf)*Fs;
plot(f,yf)
%信号滤波及时频分析
yt1=filter(b,a,yt);
figure(3);
plot(t,yt1)
plot(t,yt1);
yf1=abs(fft(yt1));
length(yf1))/length(yf1)*Fs;
plot(f,yf1)