function s1 = substruct( s, varargin )
%s1 = substruct( s, ... )
%   Set s1 to a new structure whose fields are those fields of s whose
%   names are given as arguments.

    s1 = struct();
    for i=1:length(varargin)
        f = varargin{i};
        s1.(f) = s.(f);
    end
end
