⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filtic.m

📁 有关matlab的电子书籍有一定的帮助希望有用
💻 M
字号:
function vinit = filtic( b, a, ypast, xpast )
%FILTIC Make initial conditions for 'filter' function.
%   Z = filtic( B, A, Y, X ) converts past input X and output Y
%   into initial conditions for the state variables Z needed in the
%       TRANSPOSED DIRECT FORM II filter structure.
%   The vectors of past inputs & outputs are stored with more recent
%   values first, i.e.
%          X = [ x[-1] x[-2] x[-3] ... x[-nb] ... ]
%          Y = [ y[-1] y[-2] y[-3] ... y[-na] ... ]
%   where nb = length(B)-1 and na = length(A)-1.  Short input vectors
%   X and Y are zeropadded to length nb and na respectively.  If X
%   or Y are longer than nb or na, the values beyond those lengths
%   are irrelevant to the filter's initial conditions and are ignored.
%
%   Z = filtic( B, A, Y ) assumes that X = 0 in the past.
%
%   See also FILTER.

%   Copyright (c) 1988-98 by The MathWorks, Inc.
%   $Revision: 1.13 $  $Date: 1997/12/02 18:36:46 $

if nargin == 3
   xpast = [0];   % this is the zero input condition
end
if (sum(size(a)>1)>1)|(sum(size(b)>1)>1)| ...
      (sum(size(xpast)>1)>1)|(sum(size(ypast)>1)>1)
    error('Requires vector (row or column) inputs.')
end
na = length(a);   nb = length(b);
m = max([na nb]) - 1;
if( m < 1 )
   vinit = [];  return
end
Lx = length(xpast);   Ly = length(ypast);
if( Lx < (nb-1) ),   xpast(nb-1) = 0;    end   %--- zero pad
if( Ly < (na-1) ),   ypast(na-1) = 0;    end
vinit = zeros(1,m);  vx = vinit;
% --- use filter() to do convolution
if( na-1 > 0 )
  vinit((na-1):-1:1) = filter( -a(na:-1:2)/a(1), 1, ypast(1:(na-1)) );
end
if( nb-1 > 0 )
  vx((nb-1):-1:1) = filter( b(nb:-1:2)/a(1), 1, xpast(1:(nb-1)) );
end
vinit = vinit + vx;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -