function [StaticLoopSensitivity,DCgain,num,den]=getTFdata(sys,Nstate,Ncontrol)
% get transfer function properties
% StaticLoopSensitivity is the static loop sensitivity of the transfer function.
% DCgain is the DC gain of the transfer function.
% num are the coefficients of the numerator polynominal.
% den are the coefficients of the denominator polynominal.
% sys is the multi-input multi output sstem.
% Nstate is the number of the state you want the transfer function for.
% Ncontrol is the number of the control you want the transfer function for.
% A zero term in a polynomial is assumed to be smaller then 1e-10.

[num1,den1]=tfdata(sys);
num=num1{Nstate,Ncontrol};
den=den1{Nstate,Ncontrol};
tfsys=tf(num,den)

jn=find(abs(num)>1e-10);
jd=find(abs(den)>1e-10);
nfirstnonzero=num(jn(1));
dfirstnonzero=den(jd(1));
nlastnonzero=num(jn(length(jn)));
dlastnonzero=den(jd(length(jd)));

DCgain=nlastnonzero/dlastnonzero;
StaticLoopSensitivity=nfirstnonzero/dfirstnonzero;
