function [mis, mxs, enr, yi] = osv(G,sz,nsy,slv,Py)

   mis=[]; mxs=[]; enr=[]; yi=[];
   if nargin < 5
      Py = [];
   end
   if nargin < 4
      slv=1;
   end
   if nargin < 3
      nsy = 1;
   end
   if nargin < 2
      disp('Usage: mis = minsings(G,sz)');
      return;
   end
   [mt,ny,nu,nx] = minfo(G);
   if mt ~= 'cons'
      disp('Constant matrix is required')
      return;
   end
   
   lv = slv;
   while lv <= ny
      elv = zeros(ny,1); elv(lv) = 1;
      Pyl = [Py elv];
      if nsy == sz
	 % Project and compute smallest singular value
%	 disp('Selected enough outputs to project.')
%	 Pym = Pyl;
	 Sh    = svd(Pyl.'*G);
         Se    = svd(G-Pyl*Pyl.'*G);
	 ims   = max(size(Sh));
	 mis = [mis Sh(ims)];
	 mxs = [mxs Sh(1)];
         enr = [enr, Se(1)];
	 yih=zeros(sz,1);
	 for t=1:sz
	    pc = Pyl(:,t);
	    yih(t) = find(pc==1);
	 end
	 yi = [yi yih];
      elseif nsy < sz
%	 disp(['Calls minosv recursively, num. of sel:', int2str(nsy)])
	 % Use minosv to makef futher projections.
	 [mislv, mxslv,enrlv, yilv] = osv(G,sz,nsy+1,lv+1, Pyl);
	 mis = [mis mislv]; 
	 mxs = [mxs mxslv]; 
         enr = [enr enrlv];
	 yi  = [yi yilv];
      end
      lv = lv + 1;
   end







