function theta = idRecursiveEstimationProcessParametersRbj(B,C,D,F,...
    nb,nc,nd,nf,nk,nParameters)
% idRecursiveEstimationProcessParametersRbj Helper function to construct
% the vector of free estimated parameters from the B, C, D and F polynomials.

%   Copyright 2014-2017 The MathWorks, Inc.

%#codegen
theta = zeros(nParameters,1,'like',B);
% Initial B(q)
paramPos = cast(0,'like',nb);
if any(nb>0)
    paramPos = sum(nb,2,'native');
    theta(1:paramPos) = ...
        idRecursivePolynomialModelEstimator.extractParametersFromB(B,nb,nk);
end
% Initial C(q)
if nc>0
    theta(paramPos+(1:nc)) = C(2:nc+1);
    paramPos = paramPos+nc;
end
% Initial D(q)
if nd>0
    theta(paramPos+(1:nd)) = D(2:nd+1);
    paramPos = paramPos+nd;
end
% Initial F(q)
if any(nf>0)
    theta(paramPos+(1:sum(nf,2,'native'))) = ...
        idRecursivePolynomialModelEstimator.extractParametersFromF(F,nf);
end