function Gm = mkspr(G,z);
%
% Virker darlig
%
  [mt,ny,nu,nx] = minfo(G);
  if strcmp(mt, 'syst') == 0
     disp('Usage: Gm = mkspr(G,z); where G is system');
     return
  end  
  
  n = nu;
  
  g1  = sel(G,1,1:nu);
  
  Gs  = sel(G,2:ny,1:nu);
  for i=1:n,
     g1i = sel(g1,1,i);
     [ai,bi,ci,di] = unpck(g1i);
%     [ai,bi,ci,ci] = minreal(ai,bi,ci,di);
     [zi,pi,ki] = ss2zp(ai,bi,ci,di);
     nzi = max(size(zi)); npi = max(size(pi));
     if nzi > npi
        for l=1:npi-nzi,
	   zi(nzi+l) = z;
	end
     end
     gn = zp2sys(zi,pi,ki/z);
     g1 = sbs(g1,gn);
%     [a,b,c,d] = unpck(g1); [a,b,c,d] = minreal(a,b,c,d); g1 = pck(a,b,c,d);
     g1 = sysbal(g1);
  end
  [mt,nrg1,ncg1,nxg1] = minfo(g1)
  g1n = sel(g1, 1,nu+1:nu+nu);
%  [a,b,c,d] = unpck(g1n); [a,b,c,d] = minreal(a,b,c,d); g1n = pck(a,b,c,d);
  Gm  = abv(g1n, Gs);
  Gm = sysbal(Gm);
%  [a,b,c,d] = unpck(Gm); [a,b,c,d] = minreal(a,b,c,d); Gm = pck(a,b,c,d);
end
    
