%This is made by using a equation in Multivariable feedback control page
%176.
function [Gs Gm Gms]=gms(Gtest)

ztot=zero(Gtest); ptot=pole(Gtest);
z=ztot(find(ztot>0)); p=ptot(find(ptot>0));
nz=length(z); np=length(p);

s=TF('s');
b=1;a=1;     
for i = 1:np
    b=b*(s-p(i))/(s+p(i));
end;
for i = 1:nz
    a=a*(s+z(i))/(s-z(i));
end    

Gs=minreal(tf(b*Gtest));Gm=minreal(tf(Gtest*a)); Gms=minreal(tf(b*Gtest*a));