function [mag,phas] = trfsaux(a,b,c,d,iu,w,Tsamp)
%TRFSAUX	Auxiliary function to TRFSS
%
%	[mag,phase] = trfsaux(a,b,c,d,ku,w,T)

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

[no,ns] = size(c);
nw = max(size(w));

[t,a] = balance(a);
b = t \ b;
c = c * t;
[p,a] = hess(a);	
b = p' * b(:,iu);
c = c * p;
d = d(:,iu);
if Tsamp>0 w = exp(Tsamp*w * sqrt(-1)); else w = w * sqrt(-1);end
g = ltifr(a,b,w);
g = c * g + diag(d) * ones(no,nw);
mag = abs(g)';
[ny,nx]=size(c);
for ky=1:ny
phas(:,ky) = 180*phase(g(ky,:))'/pi;
end
