% ------------------------------------------------------------------- %
% ------------------------------ matrix_cal ------------------------------- %
% ------------------------------------------------------------------- %

function [AmPC] = matrix_cal(aa1,aa2,aalist,DoY,UTsec)

%
%          The matrix of the parameterization for PCs 1-5      
%  
 
               load('Ay_para.mat')
               
               aa4=aalist(:,1);
               aa5=aalist(:,2);
               aa6=aalist(:,3);
               aa7=aalist(:,4);
               
               AmPC  = ones(5,numel(DoY));
               
               aa0    = ones(size(DoY(:)));
               A=[aa0   aa1(:)   aa2(:)  aa1(:).*aa2(:)];
               AA0 = A; [m,n]=size(AA0);
               cof  = [AA0.*(aa4*ones(1,n))  AA0.*(aa5*ones(1,n))  AA0.*(aa6*ones(1,n))  AA0.*(aa7*ones(1,n)) ];
               A     = [A cof];

               AA0 = A; [m,n]=size(AA0);

               for i=1:3
                   aa=sin(DoY(:)/(365.25/i)*2*pi)*ones(1,n); bb=cos(DoY(:)/(365.25/i)*2*pi)*ones(1,n);
                   cof=[AA0.*aa AA0.*bb];   
                   A = [A cof];
               end

               for i=1:3
                   aa=sin(UTsec(:)/3600/(24/i)*2*pi)*ones(1,n); bb=cos(UTsec(:)/3600/(24/i)*2*pi)*ones(1,n);
                   cof=[AA0.*aa AA0.*bb];   
                   A = [A cof];
               end  
               
               AmPC(1,:) = A*Ay1;
               AmPC(2,:) = A*Ay2;
               AmPC(3,:) = A*Ay3;
               AmPC(4,:) = A*Ay4;
               AmPC(5,:) = A*Ay5;

end
