function y = fcn(u)
persistent u1 ;%上1拍的输入
persistent u2 ;%上2拍的输入
persistent y1 ;%上1拍的输出
persistent y2 ;%上2拍的输入
persistent u0 ;%当前的输入
persistent y0;%当前的输出
%设置初值
if isempty(u1)
u1 = 0;
u2 = 0;
y1 = 0;
y2 = 0;
u0 = 0;
y0 = 0;
end
%传递函数代码实现
u0 = u;
y0 = (1/(114688+1))((u0 +2u1+u2) - (114688+1)y2 - 2(1-114688)*y1);
u2 = u1;%更新u2
u1 = u0;%更新u1
y2 = y1;%更新y2
y1 = y0;%更新y1
y = y0;
上面函数的差分方程为
Y(n) = (1/(114688+1))( (X(n) +2X(n-1)+X(n-2)) - (114688+1)Y(n-2) - 2(1-114688)Y(n-1))