function save_rundata(varargin)

% will create a single .mat file with name batch_name_rundata.mat
% containing possibly several variables

% 1st argument = output directory (with full path)
% 2nd argument = batch name, from output_filename in default_directories.m

mat_name = [varargin{2} '_rundata.mat'];

output_file = fullfile(varargin{1},mat_name);
 first_var = 1;
for i = 3:2:nargin
    eval([varargin{i+1} ' = varargin{' num2str(i) '};'])
    if first_var
        eval(['save(output_file, ''' varargin{i+1} ''');'])
        first_var = 0;
    else
        eval(['save(output_file, ''-append'', ''' varargin{i+1} ''');'])
    end
end