function [Gds Gdm Gdms]=gmsd(Gdtest)

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

Gds=minreal(tf(b*Gdtest)); Gdm=minreal(tf(Gdtest*a)); Gdms=minreal(tf(b*Gdtest*a));