最新matlab答案完美版.pdf
文本预览下载声明
1.已知两序列 ,
计算两序列的卷积并绘制其波形。
clear;
nx=[0:6];x1=[nx=0];x2=[(nx-5)=0];x3=.8.^nx;
x=x3.*(x1-x2);
nh=[0:6];
h1=[nh=0];h2=[(nh-5)=0];
h=h1-h2;
y=conv(x,h);
ny=0:9;
subplot(3,1,1);
stem(nx,x);
axis([-1,10,-.2,1.1]); title(x);grid
subplot(3,1,2);
stem(nh,h);
axis([-1,6,-.2,1.1]); title(h);grid
subplot(3,1,3);
stem(ny,y(1:10));
axis([-1,9,-1,5]); title(y);grid
P2.已知复指数序列 ,绘制 20 点该序列的实部和虚部。
n=0:20;
x=1.2*exp((1.5+2j)*n);
subplot(2,1,1);stem(n,real(x));title(real);grid
subplot(2,1,2);stem(n,imag(x));title(imag);grid
P3.编写长度为 5 的中值滤波器程序。原始未受干扰的序列为:
s[n]=3[n(0.5) ] n,加性噪声信号 d[n] 为随机序列,幅度 0.4,分别绘制长度
为 40 的受干扰序列,以及中值滤波器的输出。
clear
n=0:39;s=3*(0.5*n).^n;
d=0.8*(rand(1,40)-0.5);
x=s+d;y=medfilt1(x,5);
subplot(2,1,1);stem(n,x);title( 受干扰 );grid;
subplot(2,1,2);stem(n,y);title( 中值输出 );grid;
只有 medfilt1 是中值滤波器函数
基本语法为
Y = MEDFILT1(X,N)
%% X 为你想平滑的时间序列, N 为滤波器的阶数,可缺省
%% Y 为平滑后的序列
P4. 已知序列 x1[n]={2.2,3,1.5,4.2,1.8}, x2[n]= {0.8,1,1.6,0.8} ,x[n] =x1[n] ?x2[n]
(卷积),分别绘制序列 x1[n] ,x2[n] 和 x [n] 的波形。
clear;n1=0:4;n2=0:3;
x1=[2.2,3,1.5,4.2,1.4];
x2=[0.8,1,1.6,0.8];
x=conv(x1,x2);
n=0:7;
subplot(3,1,1);stem(n1,x1);title(x1);grid
subplot(3,1,2);stem(n2,x2);title(x2);grid
subplot(3,1,3);stem(n,x(1:8));title(x);grid
P5.编写 4 点滑动平均滤波器程序。原始未受干扰的序列为:
n
s[n]=3[n(0.8) ] , 加性噪声信号 d[n] 为随机序列, 幅度 0.6,受干扰的序列为:
x[n]= s[n]+ d[n] ,分别绘制长度为 40 的原始未受干扰的序列,噪声序列和
受干扰序列,以及滑动平均滤波器的输出。
n=0:39;
s=3*(0.8*n).^n;
d=1.2*(rand(1,40)-0.5);
x=s+d;
windowSize = 4;
y=filter(ones(1,wind
显示全部