function [Ncap,d]=getncap(th)
% GETNCAP 	Gets the number of data points and the number of parameters
%		for a model
%
%	[Ncap,D]=getncap(TH);
%
%	TH: The model, defined in the THETA-format (See help theta)
%	Ncap: The number of data points (samples) that were used to estimate TH
%	   (If the model is not estimated, Ncap is returned as [])
%	D: The number of estimated parameters in the model structure

%	L. Ljung 10-2-90
%	Copyright (c) 1990 by the MathWorks, Inc.
%	All Rights Reserved.


if isthss(th), d=th(1,5);else nu=th(1,3);
d=th(1,4)+sum(th(1,5:4+nu))+th(1,5+nu)+th(1,6+nu)+sum(th(1,7+nu:6+2*nu));end

alpha=(th(2,1)-th(1,1))/(th(2,1)+th(1,1));
if alpha>eps,Ncap=d/alpha;end



