function s = trimStruct( s, fields )
%s = trimStruct( s, fields )
%   Remove all fields from s except those in the cell array FIELDS.

    s1 = struct();
    for i=1:length(fields)
        fn = fields{i};
        if isfield(s,fn)
            s1.(fn) = s.(fn);
        end
    end
    s = s1;
end
