www.pudn.com > AR_MATLAB.rar > ARpredictor_SG.m


% File: ARpredictor_SG.m 
% ---------------------- 
% This file is used to calculate the nth element of s(n) in AR model. 
 
function[ARpredictor_SG] = ARpredictor_SG(a_vector, signalvector_s, p, n); 
% a_vector: the parameters a(i) i = 1, ..., p of AR model in vector form 
%       also with the order (or length) of the model p = length(a_vector) 
% signalvector_s: the generated part of signal s(n) 
% p: the order(length) of AR model. 
% n: the under generation element of signal s(n) 
ARpredictor_SG = 0; 
if (n > p) 
    for i = 1: p 
        ARpredictor_SG = ARpredictor_SG + a_vector(i) * signalvector_s(n - i); 
    end 
elseif (n == 1) 
    ARpredictor_SG = 0; % for s(1) = 0 + wgnvector_w(1) 
else 
    for i = 1: (n - 1) 
        ARpredictor_SG = ARpredictor_SG + a_vector(i) * signalvector_s(n - i); 
    end 
end