失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 利用matlab设计矩形脉冲信号 信号课程设计

利用matlab设计矩形脉冲信号 信号课程设计

时间:2020-02-22 08:53:07

相关推荐

利用matlab设计矩形脉冲信号 信号课程设计

实验一 连续信号的时域分析

一、实验目的

1、熟悉MATLAB 软件。

2、掌握常用连续信号与离散信号的MATLAB 表示方法。

二、实验设备

安装有matlab6.5 以上版本的PC 机一台。

三、实验原理

四、实验内容

1、用MATLAB表示连续信号: ,Acos(ω0 t +ϕ ),Asin(ω0 t +ϕ

)。

源程序:

clc

clear

close

syms t;

f1=6*exp(t);

f2=6*cos(3*t+6);

f3=6*sin(3*t+6);

subplot(2,2,1);

ezplot(f1,[-8,8]);

xlabel('t');

title('f(t)=6e^t');

grid on;

subplot(2,2,2);

ezplot(f2,[-8,8]);

xlabel('t');

title('f(t)=6*cos(3*t+6)');

grid on;

subplot(2,2,3)

ezplot(f3,[-8,8]);

xlabel('t');

title('f(t)=6*sin(3*t+6)');

grid on;

2.用MATLAB表示抽样信号(sinc(t))、矩形脉冲信号(rectpuls(t,

width))

及三角脉冲信号(tripuls(t, width, skew))。

源程序:

clc

clear

close

t=-6:0.01:6;

f1=sinc(t);

f2=rectpuls(t,2);

f3=4*tripuls(t,4,0);

subplot(2,2,1);

plot(t,f1);

xlabel('t');

title('f(t)=sinc(t)');

grid on;

subplot(2,2,2);

plot(t,f2);

xlabel('t');

axis([-6,6,-1,3]);

title('f(t)=rectpuls(t,2)');

grid on;

subplot(2,2,3);

plot(t,f3);

xlabel('t');

title('f(t)=tripuls(t,4,0)');

grid on;

3、编写如图3 的函数并用MATLAB 绘出满足下面要求的图形。

(1) f (−t);(2) f (t − 2);(3) f (1− 2t);(4) f (0.5t +1).

源程序:

clc

clear

close

t0=-1:0.02:14;

t1=-15:0.02:4;

t2=0:0.02:15;

t3=-7:0.02:2;

t4=-5:0.02:24;

f0=4*rectpuls(t0-6,12)+3*tripuls(t0-6,4,0);

f1=4*rectpuls(-t1-6,12)+3*tripuls(-t1-6,4,0);

f2=4*rectpuls(t2-8,12)+3*tripuls(t2-8,4,0);

f3=4*rectpuls(-2*t3-5,12)+3*tripuls(-2*t3-5,4,0);

f4=4*rectpuls(0.5*t4-5,12)+3*tripuls(0.5*t4-5,4,0);

subplot(3,2,1);

plot(t0,f0);

xlabel('t');

title('f(t)');

grid on;

subplot(3,2,2);

plot(t1,f1);

xlabel('t');

title('f(-t)');

grid on;

subplot(3,2,3);

plot(t2,f2);

xlabel('t');

title('f(t-2)');

grid on;

subplot(3,2,4);

plot(t3,f3);

xlabel('t');

title('f(1-2t)');

grid on;

subplot(3,2,5);

plot(t4,f4);

xlabel('t');

title('f(0.5*t+1)');

grid on;

实验总结:

实验二 连续时间系统的时域分析

一、实验目的

1、掌握卷积计算方法。

2、掌握函数lsim,impulse,step 的用法,lsim 为求取零状态响应,

impulse 为求取单位脉冲响应,step 为求取单位阶跃响应。

3、运用课堂上学到的理论知识,从RC、RL 一阶电路的响应中正确

区分零输入响应、零状态响应、自由响应与受迫响应。

二、实验设备

安装有matlab6.5 以上版本的PC 机一台。

三、实验原理

四、实验内容

1. 分别用函数lsim 和卷积积分两种方法求如图7 所示系统的零状态

响应。其中L=1,R=2,e(t) = ε(t),i(0− ) = 2。

源程序:

方法一:

clc

clear

close

t=0:0.01:10;

f=exp(-t);

a=[1 2];

b=[1];

y=lsim(b,a,f,t);

plot(t,y);

axis([0,10,-0.03,0.3]);

xlabel('Time(sec)');

ylabel('i(t)');

grid on;

方法二:

卷积法求零状态响应先求冲激响应为h= ε(t)

clc

clear

close

syms t x;

e=exp(-x);

h=exp(-2.*(t-x));

i=int(e.*h,x,0,t);

ezplot(i, [0 10]);

xlabel('time(sec)');

ylabel('i(t)');

title('f=exp(-t)*exp(-2t)');

grid on;

2. 求上述系统的冲激响应与阶跃响应。

一:冲激响应

源程序:

clc

clear

close

a=[1 2];

b=[0 1];

impulse(b,a,0:0.01:10);

plot(t,y);

xlable('time(sec)')

ylabel('i(t)');

grid on;

二:阶跃响应

源程序:

clc

clear

close

a=[1 2];

b=[0 1];

step(b,a,0:0.01:10);

plot(t,y);

xlable('time(sec)')

ylabel('i(t)');

axis([0,10,0,0.6]);

grid on;

五、思考题

1. 为什么连续时间系统的零状态响应为激励与冲击响应的卷积?

2. 利用卷积积分法计算系统响应应从几个方面进行?

实验三 连续信号的频域分析

一、实验目的

1. 掌握周期信号的频谱—— Fourier 级数的分析方法。

2. 深入理解信号频谱的概念,掌握典型信号的频谱以及Fourier 变换

的主要性质。

3. 掌握调制与解调的基本原理及滤波器的使用。

二、实验设备

安装有matlab6.5 以上版本的PC 机一台。

三、实验原理

四、实验内容

1. 求如图所示周期矩形脉冲信号的Fourier级数表达式,画出频谱图,并用前N次谐波合成的信号近似。

源程序:

clc

clear

close

syms t n;

T=2*pi;

N=5;

f=heaviside(t)-2*heaviside(t-T/2)+heaviside(t-T);

subplot(2,2,1);

ezplot(f,[0,2*pi]);

title('f0');

h=exp(-j*n*2*pi/T*t);

A1=int(f.*h,t,0,T);

A=2/T*A1;

for n1=-N:N

C(n1+6)=subs(A,n,n1);

end

C(6)=0;

subplot(2,2,2);

k=-N:N;

stem(k,abs(C));

ylabel('幅度');

xlabel('\Omega');

title('f1');

subplot(2,2,3);

stem(k,angle(C));

ylabel('相位');

xlabel('\Omega');

title('f2');

f3=0;

for m=-N:N

f3=f3+1/2*C(m+6)*exp(j*m*t);

end

subplot(2,2,4);

ezplot(f3,[0,2*pi]);

title('f3');

2、试用fourier()函数求下列信号的傅里叶变换F( jω) ,并画出F( jω)

(1) f (t) = te−3tε (t)

(2) f (t) = sgn(t)

(1)源程序:得F(jω)= 1/(3+ j*ω)^2

clc

clear

close

syms t F;

f=t*exp(-3*t)*heaviside(t);

F=fourier(f);

A=abs(F);

ezplot(A,[-5,5]);

xlabel('time(sec)');

ylabel('|F(jw)|');

title('f');

grid on;

(

2) 源程序:得F(jω)= -2*j/ω

clc

clear

close

syms t F;

f=2*heaviside(t)-1;

F=fourier(f);

A=abs(F);

ezplot(A,[-5,5]);

xlabel('time(sec)');

ylabel('|F(jw)|');

title('f');

grid on;

3、调制信号为一取样信号,利用MATLAB 分析幅度调制(AM)产生

的信号频谱,比较信号调制前后的频谱并解调已调信号。设载波信号

的频率为100Hz。

源程序:

clc;

clear;

close;

Fm=10;

t1=0:0.00001:0.2;

syms t q;

x=sin(2.0*pi*Fm*t)/(2.0*pi*Fm*t);

subplot(3,2,1);

ezplot(x,[0,0.2]);

title('f1');

Fx=fourier(x,q);

subplot(3,2,2);

ezplot(Fx,[-50*pi,50*pi]);

axis([-50*pi,50*pi,-0.05,0.1]);

title('f2');

y=x*cos(200*pi*t);

subplot(3,2,3);

b=subs(y,t,t1);

plot(t1,b);

title('f3');

axis([0,0.2,-1,1]);

Fy=fourier(y,q);

subplot(3,2,4);

ezplot(Fy,[-250*pi,250*pi]);

axis([-250*pi,250*pi,-0.05,0.1]);

title('f4');

z=y*cos(200*pi*t);

Fz=fourier(z,q);

G=-heaviside(q-20*pi)+heaviside(q+20*pi);

Fx1=Fz*G;

x1=2*ifourier(Fx1,q);

subplot(3,2,5);

ezplot(x1,[0,0.2]);

title('f5');

subplot(3,2,6);

ezplot(2*Fx1,[-50*pi,50*pi]);

axis([-50*pi,50*pi,-0.05,0.1]);

title('f6');

五、思考题

1、根据试验1 的结果,解释Gibbs 现象。

2、比较周期信号与非周期信号的频谱。

3、调制与解调的基本原理是什么?为什么要进行调制?

实验四连续系统的频域分析

一、实验目的:

掌握连续时间系统变换域分析的基本方法。

二、实验设备:

安装有matlab6.5以上版本的PC机一台。

三、实验原理

四、实验内容:

如图所示系统:

·对不同的RC值,用freqs函数画出系统的幅频曲线。

易求得H(jω)=1/(1+jωRC),RC的取值依次为100、10、……、0.00001时的幅频曲线。

源程序:

clc

clear

close

b=[0 1];

for c=-4:4

RC=10^c;

a=[RC

1];

freqs(b,a);

axis([-1,10^(5),-0.5,2]);

hold on

end

(b) 信号 包含了一个低频分量和一个高频分量。确定适当的RC值,滤除信号中的高频分量并画出信号 和

在 s范围内的波形。提示: |H( jω)|为最大值的 /2处对应的频率为通带截止频率ωc,首先求取|H(

jω)|并找到ωc和RC关系,然后根据题意选定ωc即可确定RC值。

由(a)中的图可知,当RC=-2时符合题意。

源程序:

clc

clear

close

t=0:0.002:0.3;

f=cos(100*t)+cos(2000*t);

subplot(2,1,1);

plot(t,f);

title('f1');

grid on;

y1=cos(100*t)/(1+j*100*10^(-2))+cos(2000*t)/(1+j*2000*10^(-2));

subplot(2,1,2);

plot(t,y1);

title('f2');

grid on;

2、信号任选,分析以下几种情况下信号的频谱和波形变化:

(1) 系统满足线性不失真条件时;

(2) 系统只满足恒定幅值条件时;

(3) 系统只满足相位条件时;

(4)系统两个条件均不满足时。

提示:利用fourier求取信号的傅立叶变换E(jω),然后设计

H( jω) = H( jω) eφ (ω )使之满足不同条件,计算R( jω)= E(jω)

H(jω)并画频谱图。

(1)源程序:

clc

clear

close

syms t v;

e=exp(-2*abs(t));

subplot(2,3,1);

ezplot(e,[-3,3]);

axis([-3,3,-0.2,2]);

Fe=fourier(e,v);

subplot(2,3,2);

ezplot(Fe,[-3,3]);

title('幅度谱');

axis([-3,3,0,2]);

i=1;

for a=-3:0.02:3

R11=subs(Fe,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,3);

plot(b,C);

title('相位谱');

axis([-3,3,-1,1]);

H1=2*exp(-j*v*1);

R1=Fe*H1;

r1=ifourier(R1,t);

subplot(2,3,4);

ezplot(r1,[-3,3]);

title('满足线性不失真条件');

axis([-3,3,-0.2,2])

subplot(2,3,5);

ezplot('abs(8/(4+v^2)*exp(-i*v))');

title('幅度谱');

axis([-3,3,0,2.2]);

i=1;

for a=-3:0.02:3

R11=subs(R1,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,6);

plot(b,C);

title('相位谱');

axis([-3,3,-3,3]);

(2)源程序:

clc

clear

close

syms t v;

e=exp(-2*abs(t));

subplot(2,3,1);

ezplot(e,[-3,3]);

axis([-3,3,-0.2,2]);

Fe=fourier(e,v);

subplot(2,3,2);

ezplot(Fe,[-3,3]);

title('幅度谱');

axis([-3,3,0,2]);

i=1;

for a=-3:0.02:3

R11=subs(Fe,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,3);

plot(b,C);

title('相位谱');

axis([-3,3,-1,1]);

H1=(1-j*v)/(1+j*v);

R1=Fe*H1;

D=abs(R1);

r1=ifourier(R1,t);

subplot(2,3,4);

ezplot(r1,[-3,3]);

title('只满足恒定幅值');

axis([-3,3,-1,2]);

subplot(2,3,5);

ezplot('4*abs(1/(4+v^2)*(1-i*v)/(1+i*v))');

title('幅度谱');

axis([-3,3,0,2]);

subplot(2,3,6)

i=1;

for a=-3:0.02:3

R11=subs(R1,v,a);

C(i)=angle(R11);

i=i+1;

end

a=-3:0.02:3;

plot(a,C);

title('相位谱');

axis([-3,3,-3,3]);

(3)源程序:

clc

clear

close

syms t v;

e=exp(-2*abs(t));

subplot(2,3,1);

ezplot(e,[-3,3]);

axis([-3,3,-0.2,2]);

Fe=fourier(e,v);

subplot(2,3,2);

ezplot(Fe,[-3,3]);

title('幅度谱');

axis([-3,3,0,2]);

i=1;

for a=-3:0.02:3

R11=subs(Fe,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,3);

plot(b,C);

title('相位谱');

axis([-3,3,-1,1]);

H1=v^2*exp(-j*v*1);

R1=Fe*H1;

r1=ifourier(R1,t);

subplot(2,3,4);

ezplot(r1,[-3,3]);

title('满足相位条件');

axis([-3,3,-4,0.2])

subplot(2,3,5);

ezplot('R1');

title('幅度谱');

axis([-3,3,-3,3]);

i=1;

for a=-3:0.02:3

R11=subs(R1,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,6);

plot(b,C);

axis([-3,3,-3,3]);

title('相位谱');

(4)源程序:

clc

clear

close

syms t v;

e=exp(-2*abs(t));

subplot(2,3,1);

ezplot(e,[-3,3]);

axis([-3,3,-0.2,2]);

Fe=fourier(e,v);

subplot(2,3,2);

ezplot(Fe,[-3,3]);

title('幅度谱');

axis([-3,3,0,2]);

i=1;

for a=-3:0.02:3

R11=subs(Fe,v,a);

C(i)=angle(R11);

i=i+1;

end

b=-3:0.02:3;

subplot(2,3,3);

plot(b,C);

title('相位谱');

axis([-3,3,-1,1]);

H1=v^2*(1-j*v)/(1+j*v);

R1=Fe*H1;

D=abs(R1);

r1=ifourier(R1,t);

subplot(2,3,4);

ezplot(r1,[-3,3]);

title('两个条件均不满足');

axis([-3,3,-0.5,7]);

subplot(2,3,5);

ezplot('4*abs(1/(4+v^2)*v^2*(1-i*v)/(1+i*v))');

title('幅度谱');

axis([-3,3,0,2]);

subplot(2,3,6)

i=1;

for a=-3:0.02:3

R11=subs(R1,v,a);

C(i)=angle(R11);

i=i+1;

end

a=-3:0.02:3;

plot(a,C);

title('相位谱');

axis([-3,3,-3,3]);

五、思考题

1、连续系统频域与复频域分析的基本方法是什么?

2、若信号经过系统不发生失真,则对系统频响有何要求?

实验五 信号采样与重建

一、实验目的

1、 深刻理解采样定理的内容。

2、掌握信号采样后的频谱。

二、实验设备

安装有matlab6.5 以上版本的PC 机一台。

三、实验原理

四、实验内容:

1、已知f (t) = Sa(2t),以fs为采样频率,对f (t)进行采样得到fa(t)

,观

察随着fs 由小变大, fa(t)频谱的变化,最后得出fa(t)与f (t)两者频谱

之间的关系。

源程序:

clc

clear

close

syms t w;

f=sin(2*t)/(2*t);

subplot(3,2,1);

ezplot(f,[-5,5]);

title('时域信号');

ff=fourier(f);

subplot(3,2,2);

ezplot(ff,[-5,5]);

title('频谱信号');

fs=1;fc=0;

for n=-6:6

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(3,2,4);

ezplot(fc,[-40,40]);

title('采样信号频谱,采样频率1');

fs=2;fc=0;

for n=-6:6

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(3,2,5);

ezplot(fc,[-40,40]);

title('采样信号频谱,采样频率2');

fs=3;fc=0;

for n=-6:6

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(3,2,6);

ezplot(fc,[-40,40]);

title('采样信号频谱,采样频率3');

fs=4;fc=0;

for n=-6:6

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(3,2,3);

ezplot(fc,[-40,40]);

title('采样信号频谱,采样频率4');

2、 由实验1 中采样得到的离散信号重建对应的连续时间信号:情况

一、f s ≥ 2f m;情况二、f s < 2f

m。提示根据内插公式重建连续时间信

号,或者根据采样后频谱通过低通滤波器的形式重建连续时间信号。

源程序:

clc

clear

close

syms t w;

f=sin(2*t)/(2*t);

subplot(4,2,1);

ezplot(f,[-5,5]);

title('时域信号');

F=fourier(f);

subplot(4,2,2);

ezplot(F,[-5,5]);

title('频谱信号');

fs=3;fc=0;

for n=-3:3

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(4,2,3);

ezplot(fc,[-35,35]);

title('采样信号频谱,fs≥2fm(fs=3)');

G=-heaviside(w-4)+heaviside(w+4);

Fc=fc*G;

f1=ifourier(Fc)/fs;

subplot(4,2,5);

ezplot(Fc,[-35,35]);

title('重建信号频谱,fs≥2fm(fs=3)');

subplot(4,2,7);

ezplot(f1,[-5,5]);

title('重建时域信号,fs≥2fm(fs=3)');

fs=0.5;fc=0;

for n=-3:3

fc=fc+(pi/2)*fs*(-heaviside(w-2-n*2*pi*fs)+heaviside(w+2-n*2*pi*fs));

end

subplot(4,2,4);

ezplot(fc,[-35,35]);

title('采样信号频谱,fs<2fm(fs=0.5)');

G=-heaviside(w-4)+heaviside(w+4);

Fc=fc*G;

f1=ifourier(Fc)/fs;

subplot(4,2,6);

ezplot(Fc,[-35,35]);

title('重建信号频谱,fs<2fm(fs=0.5)');

subplot(4,2,8);

ezplot(f1,[-5,5]);

title('重建时域信号,fs<2fm(fs=0.5)');

五、思考题

1、随着采样频率 fs 从小到大变化,fa(t) 的频谱发生怎样的变化,与

f (t)频谱之间的关系如何?与理论计算结果之间是否完全一致?如

果不一致,请分析可能是什么原因导致的?

2、 采样频率f s 分别满足情况一与情况二时,由fa (t)重建的 (t)与原信号f

(t)是否完全相同?如果不相同,试分析原因。

实验六 离散时间信号和系统分析

一、 实验目的

1. 掌握常用离散信号的MATLAB 表示方法。

2、掌握用MATLAB 计算卷积和及零状态响应的方法。

二、 实验设备

安装有matlab6.5 以上版本的PC 机一台。

三、实验原理

四、实验内容

1、用MATLAB表示离散信号: ,Asin(k)。

源程序:

clc

clear

close

k=-5:5;

fk=1.5.^(k);

subplot(1,2,1);

stem(k,fk,'filled');

axis([-5,5,0,9]);

h=-6:6;

fh=2*sin(h);

subplot(1,2,2);

stem(h,fh,'filled');

axis([-8,8,-3,3]);

2、有两离散序列 (k)={-2,-1, ,1,2}, (k)={1, ,1}用MATLAB

绘出它们的波形及 (k)+ (k)及 (k)* (k)的波形。

源程序:

clc;close;clear;

n1=-2:2;n2=-1:1;

f1=[-2 -1 0 1 2];

f2=[1 1 1];

subplot(2,2,1);

stem(n1,f1,'filled');

title('f1(n)');

subplot(2,2,2);

stem(n2,f2,'filled');

title('f2(n)');

f3=[-2 0 1 2 2];

subplot(2,2,3);

stem(n1,f3,'filled');

title('f1(n)+f2(n)');

f4=conv(f1,f2);

subplot(2,2,4);

n4=-3:3;

stem(n4,f4,'filled');

title('f1(n)*f2(n)');

3、已知离散序列波形如图11 所示,试用MATLAB 绘出满足下列要

求的序列波形。

(1)f(k-2)ε(k) (2)f(-k) (3)f(-k+2)

(4)f(k-2)ε(k-2)

源程序:

clc;

clear;

close;

n=-6:5;

f=[0 1 3 6 10 15 14 12 9 5 0 0];

subplot(3,2,1);

stem(n,f,'filled');

title('f(n)');

f1=[10 15 14 12 9 5 0 0];

n1=0:7;

subplot(3,2,2);

stem(n1,f1,'filled');

title('f(n-2)*heaviside(n)');

subplot(3,2,3);

stem(-n,f,'filled');

title('f(-n)');

subplot(3,2,4);

stem(-n+2,f,'filled');

title('f(-n+2)');

f4=[14 12 9 5 0 0];

n4=2:7;

subplot(3,2,5);

stem(n4,f4,'filled');

title('f(n-2)*heasivide(n-2)');

4、试用MATLAB 的conv()函数计算实验2 中第1 题的结果。

源程序:

clc;

clear;

close;

x1=0:0.001:10;

x2=0:0.001:10

e=exp(-x2);

h=exp(-2.*x1);

f=conv(e,h);

c=length(x1)+length(x2)-2;

x3=0:0.001:c*0.001;

plot(x3,f);

xlabel('Time(sec)');

ylabel('i(t)');

grid on;

5、假设某系统的单位函数响应h(k)= ,系统激励信号

e(k) ={1,1,1,1},求系统的零状态响应。

源程序:

clc;

clear;

close;

n1=0:3;

h=(0.8).^n1;

subplot(2,2,1);

stem(n1,h,'filled');

title('h(n)');

n2=0:3

e=[1 1 1 1];

subplot(2,2,2);

stem(n2,e,'filled');

title('e(n)');

f=conv(e,h);

n3=0:6;

subplot(2,2,3);

stem(n3,f,'filled');

title('e(n)*h(n)');

如果觉得《利用matlab设计矩形脉冲信号 信号课程设计》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。