function out_struct = rmfield2(inp_struct,del_field)
%rmfield2 - replace pitifully slow rmfield() code
% out_struct = rmfield2(inp_struct,del_field)
%
%Revision: Gane Ka-Shu Wong, November 2001
all_field = fieldnames(inp_struct);
str_command = 'out_struct = struct(';
idx = strmatch(del_field,all_field,'exact');
all_field(idx) = [];
for ii = 1:length(all_field)
if (ii>1)
str_command = [str_command, ','];
end
str_command = [str_command, '''',all_field{ii},...
''',{inp_struct.',all_field{ii},'}'];
end
str_command = char([str_command, ');']);
eval(str_command);