2024年5月7日发(作者:蛮春华)
信号分类(7.10)
tf=6;
t=0:0.1:tf;
x1=sqrt(t)+cos(t);
T=0.5;
n=0:tf/T;
x2=sqrt(n*T)+cos(n*T);
deltax=0.5;
xq=round(x2/deltax)*deltax;
subplot(1,2,1)
plot(t,x1,':')
hold on
grid on
plot(n*T,x2,'o')
stem(n*T,xq,'*')
grid on
legend(连续信号xa','离散时间信号x','数字信号xq')
subplot(1,2,2)
stairs(n*T,xq)
grid on
legend('将数字信号采样保持','恢复的连续信号曲线')
set(gcf,'color','w')
序列的分类表示方法(7.11)
1.单位脉冲序列
function [ x,n ] = impseq( np,ns,nf )
if ns>np|ns>nf|np>nf
error('输入位置参数不满足ns<=np<=nf')
else n=[ns:nf];
x=[(n-np)==0];
end
2单位阶跃序列
function [ x,n ] = stepseq(np,ns,nf)
n=[ns:nf];
x=[(n-np)>=0];
end
3基本脉冲序列
ns=0;nf=10;np=3;ns3=-2;
[x1,n1]=impseq(np,ns,nf);
[x2,n2]=stepseq(np,ns,nf);
n3=ns3:nf;x3=exp((-0.2+0.5*j)*n3);
subplot(2,2,1);stem(n1,x1);title('单位脉冲序列');
subplot(2,2,3),stem(n2,x2,'.');title('单位阶跃序列')
subplot(2,2,2),stem(n3,real(x3),'x');line([-5,10],[0,0])
title('复指数序列'),ylabel('实部')
subplot(2,2,4),stem(n3,imag(x3),'filled');line([-5,10],[0,0])
ylabel('虚部')
序列的运算和变换
1序列和
function [ y,n ] = seqadd( x1,n1,x2,n2 )
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));y1=y2;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;
end
2 序列积
function [ y,n ] = seqmult( x1,n1,x2,n2 )
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));y1=y2;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
end
3 序列位移
function [y,ny] = seqshift(x,nx,k)
y=x;
ny=nx+k;
end
4折叠
function [y,ny] = seqfold(x,nx)
y=fliplr(x);ny=fliplr(nx);
end
序列运算例题
n1=[-4:5];
x1=1.5*impseq(-1,-4,5)-impseq(3,-4,5);
subplot(2,2,1);stem(n1,x1,'.')
n2=0:20;
x2=n2.*[stepseq(0,0,20)-stepseq(8,0,20)]-10*exp(-0.3*(n2-10)).*[stepseq(10,0,
20)-stepseq(16,0,20)];
subplot(2,2,2);stem(n2,x2,'.')
n3=0:30;
x3=cos(0.07*pi*n3)+0.2*randn(size(n3));
n4=n2;
x4=x2.^2;
subplot(2,2,3);stem(n3,x3,'.');
subplot(2,2,4);stem(n4,x4,'.');
序列求和过程
ns1=-2;
x1=[0,1,2,3,4,3,2,1,0];
nf1=ns1+length(x1)-1;
nx1=ns1:nf1;
ns2=2;
x2=[2,2,0,0,0,-2,-2];
nf2=ns2+length(x2)-1;
nx2=ns2:nf2;
ny=min(ns1,ns2):max(nf1,nf2);
y1=zeros(1,length(ny));y2=y1;
y1(find((ny>=ns1&ny<=nf1)==1))=x1;
y2(find((ny>=ns2&ny<=nf2)==1))=x2;
ya=y1+y2;
yp=y1.*y2;
subplot(4,2,1);stem(nx1,x1,'.');ylabel('x1')
subplot(4,2,3);stem(nx2,x2,'.');ylabel('x2')
subplot(4,2,2);stem(ny,y1,'.');ylabel('y1')
subplot(4,2,4);stem(ny,y2,'.');ylabel('y2')
subplot(4,2,6);stem(ny,ya,'.');ylabel('ya')
subplot(4,2,8);stem(ny,yp,'.');ylabel('yp')
2024年5月7日发(作者:蛮春华)
信号分类(7.10)
tf=6;
t=0:0.1:tf;
x1=sqrt(t)+cos(t);
T=0.5;
n=0:tf/T;
x2=sqrt(n*T)+cos(n*T);
deltax=0.5;
xq=round(x2/deltax)*deltax;
subplot(1,2,1)
plot(t,x1,':')
hold on
grid on
plot(n*T,x2,'o')
stem(n*T,xq,'*')
grid on
legend(连续信号xa','离散时间信号x','数字信号xq')
subplot(1,2,2)
stairs(n*T,xq)
grid on
legend('将数字信号采样保持','恢复的连续信号曲线')
set(gcf,'color','w')
序列的分类表示方法(7.11)
1.单位脉冲序列
function [ x,n ] = impseq( np,ns,nf )
if ns>np|ns>nf|np>nf
error('输入位置参数不满足ns<=np<=nf')
else n=[ns:nf];
x=[(n-np)==0];
end
2单位阶跃序列
function [ x,n ] = stepseq(np,ns,nf)
n=[ns:nf];
x=[(n-np)>=0];
end
3基本脉冲序列
ns=0;nf=10;np=3;ns3=-2;
[x1,n1]=impseq(np,ns,nf);
[x2,n2]=stepseq(np,ns,nf);
n3=ns3:nf;x3=exp((-0.2+0.5*j)*n3);
subplot(2,2,1);stem(n1,x1);title('单位脉冲序列');
subplot(2,2,3),stem(n2,x2,'.');title('单位阶跃序列')
subplot(2,2,2),stem(n3,real(x3),'x');line([-5,10],[0,0])
title('复指数序列'),ylabel('实部')
subplot(2,2,4),stem(n3,imag(x3),'filled');line([-5,10],[0,0])
ylabel('虚部')
序列的运算和变换
1序列和
function [ y,n ] = seqadd( x1,n1,x2,n2 )
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));y1=y2;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;
end
2 序列积
function [ y,n ] = seqmult( x1,n1,x2,n2 )
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));y1=y2;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
end
3 序列位移
function [y,ny] = seqshift(x,nx,k)
y=x;
ny=nx+k;
end
4折叠
function [y,ny] = seqfold(x,nx)
y=fliplr(x);ny=fliplr(nx);
end
序列运算例题
n1=[-4:5];
x1=1.5*impseq(-1,-4,5)-impseq(3,-4,5);
subplot(2,2,1);stem(n1,x1,'.')
n2=0:20;
x2=n2.*[stepseq(0,0,20)-stepseq(8,0,20)]-10*exp(-0.3*(n2-10)).*[stepseq(10,0,
20)-stepseq(16,0,20)];
subplot(2,2,2);stem(n2,x2,'.')
n3=0:30;
x3=cos(0.07*pi*n3)+0.2*randn(size(n3));
n4=n2;
x4=x2.^2;
subplot(2,2,3);stem(n3,x3,'.');
subplot(2,2,4);stem(n4,x4,'.');
序列求和过程
ns1=-2;
x1=[0,1,2,3,4,3,2,1,0];
nf1=ns1+length(x1)-1;
nx1=ns1:nf1;
ns2=2;
x2=[2,2,0,0,0,-2,-2];
nf2=ns2+length(x2)-1;
nx2=ns2:nf2;
ny=min(ns1,ns2):max(nf1,nf2);
y1=zeros(1,length(ny));y2=y1;
y1(find((ny>=ns1&ny<=nf1)==1))=x1;
y2(find((ny>=ns2&ny<=nf2)==1))=x2;
ya=y1+y2;
yp=y1.*y2;
subplot(4,2,1);stem(nx1,x1,'.');ylabel('x1')
subplot(4,2,3);stem(nx2,x2,'.');ylabel('x2')
subplot(4,2,2);stem(ny,y1,'.');ylabel('y1')
subplot(4,2,4);stem(ny,y2,'.');ylabel('y2')
subplot(4,2,6);stem(ny,ya,'.');ylabel('ya')
subplot(4,2,8);stem(ny,yp,'.');ylabel('yp')