一、信号处理 ——impseq函数与stepseq函数(Matlab实现)

在脚本中直接运行一次即可,在matlab左侧生成impseq.m文件与stepseq.m文件

1. 单位脉冲函数impseq.

function [x,n] = impseq(n0,n1,n2)
    % 产生 x(n) = delta(n-n0); n1 <= n,n0 <= n2
    % [x,n] = impseq(n0,n1,n2)
if ((n0 < n1) | (n0 > n2) | (n1 > n2))
    error('参数必须满足 n1 <= n0 <= n2')
end
n = [n1:n2];
    %x = [zeros(1,(n0-n1)), 1, zeros(1,(n2-n0))];
x = [(n-n0) == 0];

2. 单位阶跃函数stepseq.

function [x,n] = stepseq(n0,n1,n2)
    % 产生 x(n) = u(n-n0); n1 <= n,n0 <= n2
    % [x,n] = stepseq(n0,n1,n2)
if ((n0 < n1) | (n0 > n2) | (n1 > n2))
    error('参数必须满足 n1 <= n0 <= n2')
end
n = [n1:n2];
    %x = [zeros(1,(n0-n1)), ones(1,(n2-n0+1))];
x = [(n-n0) >= 0];

仅用于学习记录~

你可能感兴趣的:(信号处理,算法)