第四章 *畅 132***224
Contents
例1 用MATLAB命令绘出连续时间信号x关于t的曲线,t的范围为0~30s,并以0.1s递增。
例2 产生周期为0.02的三角波,运行如下MATLAB程序,结果如图。
例3 产生周期为0.02的方波,运行如下MATLAB程序,结果如图。
例4 产生sinc函数波形,运行如下MATLAB程序,结果如图。
例5 运行如下MATLAB程序,得结果如图。
例6 运行MATLAB程序,结果如图。
例7 绘制一线性调频信号。
例8 产生一个2GHz的高斯单脉冲信号,采样频率为100GHz。
例9 产生一个时间为2s,采样频率为10kHz的信号,它的瞬时频率是时间的三角函数。
例10
绘制离散时间信号的棒状图。其中x(-1)=-1,x(0)=1,x(1)=2,x(2)=1,x(3)=0,x(4)=-1,其他时间x(n)=0。
例11
信号的相加与相乘。
例12
序列移位与周期延拓。
例13
求序列x(n)的翻褶序列y(n)。
例14
计算下列卷积,并图示各序列及其卷积结果。
例15
完成下列序列的相关运算,并图示各序列及其相关结果。
例1 用MATLAB命令绘出连续时间信号x关于t的曲线,t的范围为0~30s,并以0.1s递增。
t=0:0.1:30;
x=exp(-0.707*t).*sin(2/3.*t);
plot(t,x);grid;
ylabel('x(t)');xlabel('Time(see)');
例2 产生周期为0.02的三角波,运行如下MATLAB程序,结果如图。Fs=10000;t=0:1/Fs:1;
x1=sawtooth(2*pi*50*t,0);
x2=sawtooth(2*pi*50*t,1);
subplot(2,1,1),plot(t,x1),axis([0,0.2,-1,1]);
subplot(2,1,2),plot(t,x2),axis([0,0.2,-1,1]);
例3
产生周期为0.02的方波,运行如下MATLAB程序,结果如图。
Fs=10000;t=0:1/Fs:1;
x1=square(2*pi*50*t,20);
x2=square(2*pi*50*t,80);
subplot(2,1,1),plot(t,x1),axis([0,0.2,-1.5,1.5]);
subplot(2,1,2),plot(t,x2),axis([0,0.2,-1.5,1.5]);
例4
产生sinc函数波形,运行如下MATLAB程序,结果如图。
x=-4:1/1000:4;
y=sinc(x);
figure,plot(x,y);
例5 运行如下MATLAB程序,得结果如图。
t=-1:0.01:1;
y1=rectpuls(t);y2=rectpuls(t,0.8);
subplot(2,1,1),plot(t,y1),grid;
subplot(2,1,2),plot(t,y2),grid;
例6
运行MATLAB程序,结果如图。
t=-1:0.01:1;
y1=tripuls(t);
y2=tripuls(t,0.6);
subplot(2,1,1),plot(t,y1),grid;
subplot(2,1,2),plot(t,y2),grid;
例7
绘制一线性调频信号。
t=0:0.001:2;
y=chirp(t,0,1,150);
figure,plot(t,y);axis([0,0.5,-1,1]);
例8
产生一个2GHz的高斯单脉冲信号,采样频率为100GHz。
fc=2e9;fs=100e9;
tc=gmonopuls('cutoff',fc);
t=-2*tc:1/fs:2*tc;
y=gmonopuls(t,fc);
plot(t,y);grid;
例9
产生一个时间为2s,采样频率为10kHz的信号,它的瞬时频率是时间的三角函数。
fs=10000;t=0:1/fs:2;
x=vco(sawtooth(2*pi*t,0.75),[0.1,0.4]*fs,fs);
specgram(x,512,fs,kaiser(256,5),220);
例10
绘制离散时间信号的棒状图。其中x(-1)=-1,x(0)=1,x(1)=2,x(2)=1,x(3)=0,x(4)=-1,其他时间x(n)=0。
n=-3:5;
x=[0,0,-1,1,2,1,-1,0,0];
stem(n,x);grid;
line([-3,5],[0,0]);
xlabel('n');ylabel('x[n]');
例11
信号的相加与相乘。
n1=[-5:4];
n1s=-5;n1f=4;
x1=[2,3,1,-1,3,4,2,1,-5,-3];
n2=[0:9];
n2s=0;n2f=9;
x2=[1,1,1,1,1,1,1,1,1,1];
ns=min(n1s,n2s);nf=max(n1f,n2f);
n=ns:nf;
y1=zeros(1,length(n));
y2=zeros(1,length(n));
y1(find((n>=n1s)&(n<=n1f)==1))=x1;
y2(find((n>=n2s)&(n<=n2f)==1))=x2;
ya=y1+y2;
yp=y1.*y2;
subplot(4,1,1),stem(n,y1,'.');
line([n(1),n(end)],[0,0]);ylabel('x1(n)');
subplot(4,1,2),stem(n,y2,'.');
line([n(1),n(end)],[0,0]);ylabel('x2(n)');
subplot(4,1,3),stem(n,ya,'.');
line([n(1),n(end)],[0,0]);ylabel('x1(n)+x2(n)');
subplot(4,1,4),stem(n,yp,'.');
line([n(1),n(end)],[0,0]);ylabel('x1(n).x2(n)');
例12
序列移位与周期延拓。
N=24;M=8;m=3;
n=0:N-1;
x1=(0.8).^n;
x2=[(n>=0)&(n
x=x1.*x2;
xm=zeros(1,N);
for k=m+1:m+M
xm(k)=x(k-m);
end
xc=x(mod(n,M)+1);
xcm=x(mod(n-m,M)+1);
subplot(4,1,1),stem(n,x,'.');ylabel('x(n)');
subplot(4,1,2),stem(n,xm,'.');ylabel('x(n-3)');
subplot(4,1,3),stem(n,xc,'.');ylabel('x((n))_8)');
subplot(4,1,4),stem(n,xcm,'.');ylabel('x((n-3))_8');
例13
求序列x(n)的翻褶序列y(n)。
n=0:10;
x=3*exp(-0.2*n);
y=fliplr(x);
n1=-fliplr(n);
n2=fliplr(-(n-3));
subplot(2,1,1),stem(n,x);
xlabel('n');ylabel('x[n]');
subplot(2,1,2),stem(n1,y);
xlabel('n');ylabel('y[n]=x[-n]');
s=cumsum(x);
figure;
subplot(2,1,1),stem(n2,y);
xlabel('n');ylabel('y[n]=x[-n+3]');
subplot(2,1,2),stem(n,s);
xlabel('n');ylabel('s[n]');
例14
计算下列卷积,并图示各序列及其卷积结果。
(1) y1(n)=x1(n)*h1(n), (2) y2(n)=x2(n)*h2(n),
Nx=20;Nh=10;m=5;
n=0:Nx-1;
x1=(0.9).^n;
x2=zeros(1,Nx+m);
for k=m+1:m+Nx
x2(k)=x1(k-m);
end
nh=0:Nh-1;h1=ones(1,Nh);
h2=h1;
y1=conv(x1,h1);
y2=conv(x2,h2);
subplot(3,2,1),stem(x1);xlabel('n');ylabel('x1[n]');
subplot(3,2,2),stem(x2);xlabel('n');ylabel('x2[n]');
subplot(3,2,3),stem(h1);xlabel('n');ylabel('h1[n]');
subplot(3,2,4),stem(h2);xlabel('n');ylabel('h2[n]');
subplot(3,2,5),stem(y1);xlabel('n');ylabel('y1[n]');
subplot(3,2,6),stem(y2);xlabel('n');ylabel('y2[n]');
例15
完成下列序列的相关运算,并图示各序列及其相关结果。
(1) y1(m)=求和x1(n)h1(n-m), (2) y2(m)=求和x2(n)h2(n-m),
Nx=20;Nh=10;m=5;
n=0:Nx-1;
x1=(0.9).^n;
x2=zeros(1,Nx+m);
for k=m+1:m+Nx
x2(k)=x1(k-m);
end
nh=0:Nh-1;h1=ones(1,Nh);
h2=h1;
y1=xcorr(x1,h1);
y2=xcorr(x2,h2);
subplot(3,2,1),stem(x1);xlabel('n');ylabel('x1[n]');
subplot(3,2,2),stem(x2);xlabel('n');ylabel('x2[n]');
subplot(3,2,3),stem(h1);xlabel('n');ylabel('h1[n]');
subplot(3,2,4),stem(h2);xlabel('n');ylabel('h2[n]');
subplot(3,2,5),stem(y1);xlabel('n');ylabel('y1[n]');
subplot(3,2,6),stem(y2);xlabel('n');ylabel('y2[n]');
Published with MATLAB® R2014a