function [Gs2 Gm2 Gms2]=gms2(G2)

ztot=zero(G2); ptot=pole(G2);
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    

Gs2=minreal(tf(b*G2));Gm2=minreal(tf(G2*a)); Gms2=minreal(tf(b*G2*a));
