MATLAB机考样题(带答案)
更新时间:2023-09-03 02:56:01 阅读量: 教育文库 文档下载
MATLAB机考样题:
(1)Generate and plot sequence
with 20 n 20.
n1=-20:20;
x1=2*cos(pi/8*n1);
n2=n1-4;
x2=2*cos(pi/8*n2);
subplot(2,1,1);
plot(n1,x1);
subplot(212);
plot(n2,x2); x1[n] 2cos(n) and x2[n] x1[n 4], 8
(2)Write a MATLAB program to compute and plot the impulse response of a causal finite-dimensional discrete-time system characterized by a difference equation of the following form:
y[n] 0.3y[n-1] 0.5y[n-2]-0.72y[n-3] 1.8x[n] 0.34x[n-1] 1.32x[n-2] 0.86x[n-3]
N=input('请输入你要求的点数N=');
num=[1.8 0.34 -1.32 -0.86];
den=[1 0.3 0.5 -0.72]; x=[1 zeros(1,N-1)];(单位冲击)
y=filter(num,den,x);
plot(0:N-1,y);
(3)Write a MATLAB program to compute and display the poles and zeros, to compute and display the second-order factored form, and to generate the pole-zero plot of a z-transform that is a ratio of two polynomials in z-1. Using this program to analyze the following G(z):
8.1 6.93z 1 23.82z 2 10.5z 3
H(z) 1 1.52z 1 0.18z 2 0.1768z 3
num=[8.1 6.93 -23.82 10.5];
den=[1 1.52 0.18 -0.1768];
sos=tf2sos(num,den) %tf2sos表示为1/z的升幂
zplane(num,den)
(4)Try to give a program to evaluate the following DTFT in the range 0 :
2 5e j 9e j2 5e j3 3e j4
G1(z) 5 45e j 2e j2 e j3 e j4
%由于用freqz计算频点至少是2个,所以至少输入两个频点
w1=input('请输入你要计算的频点w1=');
w2=input('请输入你要计算的频点w2=');
w=[w1 w2];
num=[2 5 9 5 3];
den=[5 45 2 1 1];
h=freqz(num,den,w)
(6)Write a MATLAB program to compute and plot the magnitude response of a causal LTI discrete-time system with a transfer function given by
0.15(1 z 2)H(z) 1 0.5z 1 0.7z 2
num=0.15*[1 0 -1];
den=[1 -0.5 0.7];
[h,w]=freqz(num,den,512);
plot(w/pi,abs(h));
(7)Consider the following FIR transfer function:
H(z) 1 0.6z 1 0.49z 2 0.48z 3 0.14z 4 0.12z 5 0.09z 6
Using MATLAB to determine its zero locations and plot its magnitude and phase response.
h=[1 0.6 .49 -0.48 -0.14 -0.12 0.09];
figure(1)
zplane(h,1);
[H,w]=freqz(h,1,512);
figure(2)
plot(w/pi,abs(H));
figure(3)
plot(w/pi,angle(H));
(8)Given a signal x(t) 4t cos0.1 t, when using a sampling frequency fT= 20KHz, plot the magnitude and phase spectrum of the sampled sequence(given length-64).
fs=2e4;
n=0:63;
x=4*n/fs+cos(0.1*pi*n/fs);
h=fft(x,1024);
figure(1);
plot(0:2/1023:2,abs(h));
figure(2);
plot(0:2/1023:2,angle(h));
(9)design an IIR butterworth digital lowpass filter with the following specifications: sampling rate of 40kHz, passband edge frequency of 4kHz, stopband edge frequency of 8kHz, passband ripple of 0.5dB, and a minimum stopband
attenuation of 40dB,plot frequency-magnitude and check if your design fits the specification.
fs=40; wp=4*2/fs; %wp<1,没有乘pi
ws=8*2/fs; %ws<1,没有乘pi
ap=0.5;
as=40;
[n,wn]=buttord(wp,ws,ap,as);
[num,den]=butter(n,wn);
[h,w]=freqz(num,den,512);
figure(1);
plot(w/pi,20*log10(abs(h)));
axis([0 1 -50 0]);
figure(2);
subplot(2,1,1);
plot(w/pi,20*log10(abs(h)))
axis([0 wp -0.5 0]);
title('通带纹波');
subplot(2,1,2);
plot(w/pi,20*log10(abs(h)));
axis([ws 1 -50 -30]);
title('阻带纹波');
(10)Design a Hanning FIR lowpass filter meeting the following specifications: passband edge frequency=2kHz, stopband edge frequency=2.5kHz, passband ripple δp=0.005, stopband rippleδs=0.005, and sampling rate of 10kHz.Plot its gain and phase responses and check if it meets the specifications?
ft=10;
fp=2;
fs=2.5;
wp=2*pi*fp/ft;
ws=2*pi*fs/ft;
ds=0.005;
ap=20*log10(1-ds)
as=20*log10(ds)
wc=(wp+ws)/2;
dw=ws-wp;
M=ceil(3.11*pi/dw);
N=2*M;
b=fir1(N,wc/pi,hann(N+1));
[h,w]=freqz(b,1,512);
figure(1);
plot(w/pi,20*log10(abs(h)));
axis([0 1 -50 0]);
title('magitude response');
figure(2);
plot(w/pi,unwrap(angle(h)));
title('phase response');
figure(3);
subplot(211);
plot(w/pi,20*log10(abs(h)));
axis([0 wp/pi ap 0]);
title('通带纹波')
subplot(212);
plot(w/pi,20*log10(abs(h)));
axis([ws/pi 1 as 0]);
title('阻带纹波');
%从图中可以看出,通带和阻带中纹波都不满足要求,所以不
满足指标
%as= -46.0206<43.9 所以不能用hanning窗设计
%应当用hamming或blackman窗设计
(11)Writing a MATLAB program to compute 128-point DFT of the following
sequence, you must firstly use DFT definition (directly computing DFT) to compute and use MATLAB function to test the result. Plot the two results in one figure.
n=0:31;
k=1:128;
x=sin(pi*n/4);
Xk1=zeros(1,128);
for t=1:128 g[n] sin( 4),0 n 31 for m=1:32
Xk1(t)=Xk1(t)+x(m)*exp(-1i*2*pi*(t-1).*(m-1)/128);
end
end
subplot(2,1,1);
plot(k,Xk1);
Xk2=fft(x,128);
subplot(2,1,2);
plot(k,Xk2);
(12)Using the function fir1 and window of Kaiser, design a linear-phase FIR lowpass filter meeting the following specifications: passband edge frequency=2kHz, stopband edge frequency=2.5kHz, passband ripple δp=0.005, stopband rippleδs=0.005, and sampling rate of 10kHz.Plot its gain and phase responses and check if it meets the specifications?
Design a Type 1 Chebyshev IIR lowpass filter meeting the specifications as below: sampling rate of 12kHz, passband edge frequency of 2.1kHz, stopband edge frequency of 2.7kHz, passband
ripple of 0.6dB, and a minimum stopband attenuation of 45dB. Write down the exact expression for the transfer function generated. Does your design meet the specifications?
Fp=2100;Fs=2700;
Ft=12000;
Rp=0.6;Rs=45;
Wp=2*Fp/Ft;
Ws=2*Fs/Ft;
[N,Wn]=cheb1ord(Wp,Ws,Rp,Rs)
[B,A]=cheby1(N,Rp,Wn)
[h,w]=freqz(B,A,512);
figure(1);
plot(w/pi,20*log10(abs(h)));
axis([0 1 -50 0]);
figure(2);
subplot(2,1,1);
plot(w/pi,20*log10(abs(h)))
axis([0 Wp -0.6 0]);
title('通带纹波');
subplot(2,1,2);
plot(w/pi,20*log10(abs(h)));
axis([Ws 1 -50 -30]);
title('阻带纹波');
(13)Using the function fir1 and window of Kaiser, design a linear-phase FIR lowpass filter meeting the following specifications: passband edge frequency=2kHz, stopband edge frequency=2.5kHz, passband ripple δp=0.005, stopband rippleδs=0.005, and sampling rate of 10kHz.Plot its gain and phase responses and check if it meets the specifications?
[n,wn,beta,typ]=kaiserord([2000 2500],[1 0],[0.005 0.005],10000); b=fir1(n,wn,kaiser(n+1,beta),'noscale');
[h,omega]=freqz(b,1,256);
subplot(2,1,1);
plot(omega/pi,20*log10(abs(h)));
xlabel('\omega/\pi'); ylabel('Gain, dB');
subplot(2,1,2)
plot(omega/pi,angle(h));grid
title('Phase Spectrum');
xlabel('\omega/\pi'); ylabel('Phase, radians');
(14)Given a signal when using a sampling frequency fT= 20KHz, plot the magnitude and phase spectrum of the sampled sequence(given
length-64). x(t) sin(0.1 t) 2cos(0.3 t) 3sin(0.5 t)
ft=20000;
n=1:64;
x=sin(0.1*pi*n/ft)+2*cos(0.3*pi*5*n/ft)+3*sin(0.5*pi*n/ft); subplot(2,1,1);
[h,w]=freqz(x,1,256);
plot(w/pi,abs(h));
title('Magnitude spectrum of the sampled samples');
xlabel('\omega/\pi'); ylabel('Magnitude');
subplot(2,1,2);
plot(w/pi,angle(h));
title('Phase spectrum of the sampled samples');
xlabel('\omega/\pi'); ylabel('Phase');
(15)Write a MATLAB program to compute the first L samples of the inverse of rational z-transforms where the value of L is provided by the user through the command input. Using this program to compute and plot the first 50 samples of the inverse of following G(z). Use the command stem for plotting the sequence generated by the inverse transform 108 G3(z) 2 4 z 1 2 z 1,|z| 0.5
L=input('input the L=');
r=[10/4 -8/2];
p=[-1/4 -1/2];
k=-2;
[B,A]=residuez(r,p,k)
[h t]=impz(B,A,L)
stem(t,h);
Writing a MATLAB program to compute the circular convolution of two length-N sequences via the DFT-based approach. Using this program to determine the following pair of sequences:
g[n]={7, 4, -9, 0, 2, -5}, h[n]={1, -1, 2, 0, 10, 5} or
And plot the result sequence
x1=[7 4 -9 0 2 -5];
x2=[1 -1 2 0 10 5];
L=length(x1);
y=zeros(1,L);
x2tr = [x2(1) x2(L:-1:2)];
for k = 1:L,
sh = circshift(x2tr', k-1)';
h = x1.*sh;
y(k) = sum(h);
end
disp(y);
n=0:length(x1)-1;
stem(n,y);
n=0:50;
x=sin(5*pi*n/16);
stem(n,x); %或者如下 syms n1; %x1=x’ x1=sin(5*pi*n1/16).^2;
y=symsum(x1,n1,0,50)
y1=double(y)
%y=x*x1
正在阅读:
MATLAB机考样题(带答案)09-03
民用建筑工程室内环境污染控制规范04-06
街道铁路护路联防工作方案05-22
通达信指标公式源码本公式最大的优点就是逃顶100%,07-09
节水护水主题班会d 文档(2)04-12
天津市静海区2019届高三化学上学期12月四校联考试卷 doc03-05
1.0MPa钢丝管与PE管材综合对比02-28
部分电视工程菜单进入方法05-29
新冠肺炎疫情联防联控工作汇报12-12
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 答案
- MATLAB
- 新目标英语九年级单词拼写总复习
- 01ps制作立体感包装盒
- 神州AOI作业指导书 (1)
- 18春电大《管理学基础》形考任务四
- 透镜练习题_八年级上册物理第三章透镜及其应用测试题及答案
- Writing a memo
- 高三语文下定义专题教案
- 当代大学生心理素质的调查研究
- 湘教版初中地理新课程标准解读和教材分析
- 越冬维护施工方案
- 配电变压器一、二次侧额定电流计算表
- 赫章县古基镇防性侵“十严格、十不准”目标责任书(中心同学校)
- 南昌大学 个人简历模板
- 网上购物系统数据流图
- NDJ-5S旋转粘度计使用说明书标准操作规程编写材料
- k12教育
- 贝伐单抗联合化疗一线治疗转移性结直肠癌有效性和安全性的系统评价
- 模拟电子技术基础5.1-5.5
- 九中作文序列训练
- 小班化教学听课心得