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,9-9-94
%	Copyright (c) 1986-95 by the MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1995/05/10 21:36:59 $

if nargin < 1
   disp('Usage: [NUMBER_OF_DATA,NUMBER_OF_PARS] = GETNCAP(TH)')
   return
end

Ncap=[];
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



