function globs=mkvars(St,j)
% function mkvars(St,j)
% Recreates variable(s) with indices in j from the structure St
% If j is omitted, create all variables
% getting the field names and making them global in mkvars
flds=fieldnames(St);
[nrowf,ncolf]=size(flds);
globs='global ';
if nargin<2
   j=1:nrowf;
end
for kf=j
   globs=[globs,flds{kf,1},' '];
end
eval(globs)
[nrowS,ncolS]=size(St);
for kf=j
   eval(['ichar=ischar(St(1,1).',flds{kf,1},');'])
   eval([flds{kf,1},'=[];'])
   if ichar
      for kS=1:ncolS
         eval([flds{kf,1},'=cgrp(',flds{kf,1},',St(1,kS).',flds{kf,1},');'])
      end
	  eval([flds{kf,1},'=char(',flds{kf,1},');'])
   else
      for kS=1:ncolS
         eval([flds{kf,1},'(kS,:)=St(1,kS).',flds{kf,1},';'])
      end
   end
end
