0001 function dsExportData(data,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 options=dsCheckOptions(varargin,{...
0020 'filename','data.mat',[],...
0021 'format','mat',[],...
0022 'matCompatibility_flag',1,{0,1},...
0023 'verbose_flag',0,{0,1},...
0024 },false);
0025
0026 switch lower(options.format)
0027 case 'mat'
0028 if numel(data)==1
0029
0030
0031 vars=fieldnames(data);
0032 for i=1:length(vars)
0033 eval(sprintf('%s=data.%s;',vars{i},vars{i}));
0034 end
0035 if options.matCompatibility_flag
0036 try
0037 save(options.filename,vars{:},'-v7');
0038 catch
0039 fprintf('Data is not ''-v7'' compatible. Setting ''matCompatibility_flag'' to 0.\n')
0040 options.matCompatibility_flag = 0;
0041 if strcmp(reportUI,'matlab')
0042 save(options.filename,vars{:},'-v7.3');
0043 else
0044 save(options.filename,vars{:},'-hdf5');
0045 end
0046 end
0047 else
0048 if strcmp(reportUI,'matlab')
0049 save(options.filename,vars{:},'-v7.3');
0050 else
0051 save(options.filename,vars{:},'-hdf5');
0052 end
0053 end
0054 else
0055 if options.matCompatibility_flag
0056 try
0057 save(options.filename,'data','-v7');
0058 catch
0059 fprintf('Data is not ''-v7'' compatible. Setting ''matCompatibility_flag'' to 0.\n')
0060 options.matCompatibility_flag = 0;
0061 if strcmp(reportUI,'matlab')
0062 save(options.filename,'data','-v7.3');
0063 else
0064 save(options.filename,'data','-hdf5');
0065 end
0066 end
0067 else
0068 if strcmp(reportUI,'matlab')
0069 save(options.filename,'data','-v7.3');
0070 else
0071 save(options.filename,'data','-hdf5');
0072 end
0073 end
0074 end
0075 case 'csv'
0076
0077
0078 case 'hdf'
0079
0080 otherwise
0081
0082 end
0083
0084 if options.verbose_flag
0085 fprintf('\tData saved to %s\n',options.filename);
0086 end