butterworth.m
来自「信号分析信号分析信号信号分析分析信号分析信号分析」· M 代码 · 共 33 行
M
33 行
function Y = butterworth(X,freq,n)
% PURPOSE: computes the cyclical component of given time series using the Butterworth
% filter
%
% INPUT:
% X - time series (T x K)
% n - order of the Butterworth filter
% freq - cut-off frequency - number of periods per cycle
%
% OUTPUT:
% Y - cyclical component of X
%
% written by:
% Pawel Kowal
% Department of Economics
% Warsaw School of Economics
% pkowal3@sgh.waw.pl
T = size(X,1);
cut_off = 2*pi/freq;
mu = (1/tan(cut_off/2))^(2*n);
I = speye(T);
LT = spdiags(ones(T-1,1),-1,T,T);
LT = (I-LT)^n;
Q = LT(3:end,:)';
SIGMA_R = Q'*Q;
SIGMA_T = abs(SIGMA_R);
g = Q'*X;
b = (SIGMA_T+mu*SIGMA_R)\g;
Y = mu*Q*b;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?