% DEMO_GPCMP.M
% Example of how to solve the Diophantine equations and obtain
% the Prediction Model (PM) used by the GPC method.

a1=-0.8; b0=0.4; b1=0.6;
A=[1 a1];    % The polynomial A=a0 + a1z^{-1}
B=[b0 b1];   % The polynomial B=b0 + b1z^{-1}

% Solving for the F_j, E_j and G_j polynomials. Only the coefficients in
% the F_j and G_j polynomials are used in the PM.
% NOTE: In the following we are using: z:=z^{-1} for simplicity of notation.
na=length(A); nb=length(B);
At=conv([1 -1],A)                 % At=(1-z)*A

%%% The F_j polynomials, j=1,2,...L where F_j=f_j0+f_j1*z+...f_jna*z^na
F1=-At(2:na+1)                    % F1=z*(1-At)=f10+f11*z
% j=1, merk f12=0
f20=F1(2)-F1(1)*At(2);
f21=     -F1(1)*At(3);
F2=[f20 f21]

% j=2
f30=f21-f20*At(2);
f31=   -f20*At(3);
F3=[f30 f31]

% j=3
f40=f31-f30*At(2);
f41=   -f30*At(3);
F4=[f40 f41]

%%% The E_j polynomials
E1=1;
f10=F1(1);
E2=[E1 f10]
E3=[E2 f20]
E4=[E3 f30]

%%% The G_j polynomials using the MATLAB function conv.m to multiply polynomials.
G1=conv(E1,B)
G2=conv(E2,B)
G3=conv(E3,B)
G4=conv(E4,B)

