%序列相加
clc;
clear;
x1=[1,2,3,4,5];
k1=-1:3;
x2=[5,6,7];
k2=2:4;
k=min([k1,k2]):max([k1,k2]);
f1=zeros(1,length(k));
f2=zeros(1,length(k));
f1(find((k>=min(k1))&(k<=max(k1))==1))=x1;
f2(find((k>=min(k2))&(k<=max(k2))==1))=x2;
f=f1+f2;
subplot(3,1,1);
stem(k1,x1,'filled');
axis([-1,4,0,15]);
title('f1');
grid on;
subplot(3,1,2);
stem(k2,x2,'filled');
title('f2');
grid on;
axis([-1,4,0,15]);
subplot(3,1,3);
stem(k,f,'filled');
title('f');
grid on;
%序列相乘
clc;
clear;
x1=[1,2,3,4,5];
k1=-1:3;
x2=[5,6,7];
k2=2:4;
k=min([k1,k2]):max([k1,k2]);
f1=zeros(1,length(k));
f2=zeros(1,length(k));
f1(find((k>=min(k1))&(k<=max(k1))==1))=x1;
f2(find((k>=min(k2))&(k<=max(k2))==1))=x2;
f=f1.*f2;
subplot(3,1,1);
stem(k1,x1,'filled');
axis([-1,4,0,15]);
title('f1');
grid on;
subplot(3,1,2);
stem(k2,x2,'filled');
title('f2');
grid on;
axis([-1,4,0,15]);
subplot(3,1,3);
stem(k,f,'filled');
title('f=f1*f2');
grid on;
%序列的翻转
clc;
clear;
f1=[1,2,3,4,5];
k1=-1:3;
k=-fliplr(k1);
f=fliplr(f1);
subplot(2,1,1);
stem(k1,f1,'filled');
axis([-3,3,0,5]);
title('f1');
grid on;
subplot(2,1,2);
stem(k,f,'filled');
title('f1的翻转序列');
axis([-3,3,0,5]);
grid on;
%序列的倒相
f1=[1,2,3,4,5];
k1=-1:3;
k=k1;
f=-f1;
subplot(2,1,1);
stem(k1,f1,"filled");
axis([-1,3,-5,5]);
title('f1');
grid on;
subplot(2,1,2);
stem(k,f,"filled");
title("f1的倒相序列");
axis([-1,3,-5,5]);
grid on;
%序列的平移
clc;
clear;
f1=[1,2,3,4,5];
k1=-1:3;
k0=2;
k=k1+k0;
f=f1;
subplot(2,1,1);
stem(k1,f1,"filled");
axis([-1,5,0,5]);
title('f1');
grid on;
subplot(2,1,2);
stem(k,f,"filled");
title('f1的移位序列');
axis([-1,5,0,5]);
grid on;
%练习
clc;
clear;
f1=[0,1,2,3,4,3];
k1=1:6;
subplot(4,1,1);
stem(k1,f1,"filled");
f2=[2,2,0,0,0,-2,-2];
k2=2:8;
subplot(4,1,2);
stem(k2,f2,"filled");
k=1:8;
f1=[0,1,2,3,4,3,0,0];
f2=[0,2,2,0,0,0,-2,-2];
f3=f1+f2;
subplot(4,1,3);
stem(k,f3,"filled");
f4=f1.*f2;
subplot(4,1,4);
stem(k,f4,"filled");
离散时间信号的基本运算
最新推荐文章于 2024-01-22 21:43:28 发布