clcclearclose alln1 = 0;n2 = 5;n0 = 3;n = [n1:n2];x = [(n - n0) == 0];stem(n,x,'filled');ylim([-1,2]);1.2.3.4.5.6.7.8.9.10.11.12.
改成一个函数:
function [x,n]=delta(n0,n1,n2);% generate x(n) = delta(n - n0); n1 <= n <= n2%_____________________________________________%[x,n] = delta(n0, n1, n2);%n = [n1:n2];x = [(n-n0) == 0];1.2.3.4.5.6.7.
命名为delta.m
新建一个脚本:
n0 = 3;n1 = -3;n2 = 6; [x,n] = delta(n0,n1,n2);stem(n,x,'filled');ylim([-1,2]);1.2.3.4.5.6.7.8.
运行得到:
直接写成函数形式吧:
function [x,n]=stepseq(n0,n1,n2);% generate x(n) = u(n - n0); n1 <= n <= n2%_____________________________________________%[x,n] = stepseq(n0, n1, n2);%n = [n1:n2];x = [(n-n0) >= 0];1.2.3.4.5.6.7.
新建一个脚本,测试:
clcclearclose alln0 = 3;n1 = -3;n2 = 6; [x,n] = stepseq(n0,n1,n2);stem(n,x,'filled');ylim([-1,2]);1.2.3.4.5.6.7.8.9.10.11.12.
结果:
为一般形式。
下面产生一个序列:
脚本代码:
clcclearclose alln = -3:10;x = 0.9.^n;stem(n,x,'filled');xlabel('n');ylabel('0.9^n');xlim([-5,13]);ylim([0,2]);1.2.3.4.5.6.7.8.9.10.11.12.
clcclearclose alln = 0:10;x = exp( (2+3j)*n );stem(n,x);xlabel('n');1.2.3.4.5.6.7.8.9.
clcclearclose alln = 0:10;x = exp( (2+3j)*n );subplot(2,1,1)stem(n,x);xlabel('n');title('Not Period Sequence');% the number of periodP = 5; xtilde = x' * ones(1,P);xtilde = xtilde(:)';subplot(2,1,2);stem(xtilde);title('Period Sequence');1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删