function theta = idRecursiveEstimationProcessParametersRarmax(A,B,C,na,nb,nc,nk,nParameters)
% idRecursiveEstimationProcessParametersRarmax Helper function to construct
% the vector of free estimated parameters from the A, B and C polynomials.
% It is assumed that A(1)=1 and C(1)=1

%   Copyright 2013-2017 The MathWorks, Inc.

%#codegen
theta = zeros(nParameters,1,'like',A);
% Initial A(q)
endIdx = na;
if na>0
    theta(1:endIdx) = A(2:end);
end
% Initial B(q)
startIdx = na+1;
endIdx = na+sum(nb,2,'native');
if any(nb>0)
    theta(startIdx:endIdx) = ...
    idRecursivePolynomialModelEstimator.extractParametersFromB(B,nb,nk);
end
% Initial C(q)
if nc>0
    startIdx = endIdx+1;
    theta(startIdx:nParameters) = C(2:nc+1);
end