📄 arma.m
字号:
function [x,y] = arma (u,theta,x,n,m)
%-----------------------------------------------------------------------
% Usage: [x,y] = arma (u,theta,x,n,m)
%
% Description: Compute the output of an auto-regressive moving-average
% (ARMA) model having the following transfer function:
%
% Y(z) theta(n+1) + ... + theta(n+m+1)*z^(-m)
% ---- = -------------------------------------------
% U(z) 1 + theta(1)*z^(-1) + ... + theta(n)*z^(-n)
%
% Inputs: u = system input
% theta = (n+m+1) by 1 vector of system parameters:
% [a1,...,an,b0,...,bm]'
% x = (n+m+1) by 1 vector containing system state:
% [-y(k-1),...,-y(k-n),u(k),u(k-1),...,u(k-m)]'
% n = number of past outputs used (n >= 0)
% m = number of past inputs used (m >= 0)
%
% Outputs: x = (n+m+1) \times 1 vector containing updated
% system state with x(n+1) = 0.
% y = the system output.
%-----------------------------------------------------------------------
% Initialize
chkvec (theta,2,'arma');
chkvec (x,3,'arma');
m = args (m,0,m,4,'arma');
n = args (n,0,n,5,'arma');
y = 0;
r = n + m + 1;
% Compute y
x(n+1) = u;
for i = 1 : r
y = y + theta(i)*x(i);
end
% Update
for i = r : -1 : 2
x(i) = x(i-1);
end
if n > 0
x(1) = -y;
end
x(n+1) = 0;
%-----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -