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) 1986-95 by the MathWorks, Inc.
%	$Revision: 1.2 $  $Date: 1995/01/24 00:54:03 $

[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
