function thn=sett(th,T);
%SETT	Sets the sampling interval in TH-structures
%	or for frequency functions generated by spa, etfe, th2ff, or trf
%	with a default choice of frequencies.
%
%	THN = sett(TH,T)  or GN = sett(G,T)
%
%	TH:  The original model in THETA-format
%	T:   The sampling interval
%	THN: The new model in THETA-format, with sampling interval T 
%	or
%	G:   The original frequency function
%	GN:  The frequency function with frequencies scaled according to
%	     the desired sampling interval

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

[nr,nc]=size(th);thn=th;
if nr==129
	test=rem(th(1,:),1000); tt=test(1);
	if floor(tt)==tt & tt>=100 & tt<=119 %Then we have freqfunc case
	freqind=find(test>=100);
	spind=find(test==0);sdind=find(test==50);frspind=find(test==100);
	Tcurrent=(ones(1,length(freqind))*pi)./th(129,freqind);
	Tspc=(ones(1,length(frspind))*pi)./th(129,frspind);
	thn(2:129,freqind)=thn(2:129,freqind).*(ones(128,1)*Tcurrent)/T;
	if ~isempty(spind)
	  thn(2:129,spind)=thn(2:129,spind)./(ones(128,1)*Tspc)*T;
	end
	if ~isempty(sdind)
	  thn(2:129,sdind)=thn(2:129,sdind)./(ones(128,1)*Tspc)*T;
	end
end,else
if isthss(th),if any(th(2,8)==[1 5]),thn(1,2)=-abs(T);else thn(1,2)=T;end,
else
thn(1,2)=T;
end
end
