source: prdatasets/pr_savematfile.m @ 139

Last change on this file since 139 was 137, checked in by bduin, 5 years ago
File size: 1005 bytes
Line 
1%PR_SAVEMATFILE Save matfile(s) for calling mfile
2
3function varargout = pr_savematfile(varargin)
4% nout: number of outputs of calling function
5%       nout = 1: combine all files into varargout{1}
6%       nout > 1: return separate files unchanged
7% For any nout, all combined and single datasets are stored
8
9name = pr_callername;
10matfile = fullfile(fullfile(fileparts(which(name)),'data'),name);
11
12varargout = cell(1,nargout);
13if nargin == 1
14  a = varargin{1};
15  save(matfile,'a');
16  varargout{1} = a;
17else
18  if nargout == 1
19    a = vertcat(varargin{:});
20    a = setname(a,name);
21    save(matfile,'a');
22    varargout{1} = a;
23    for i=1:nargin
24      a = varargin{i};
25      save([matfile '_' num2str(i)],'a');
26    end
27  else
28    a = vertcat(varargin{:});
29    a = setname(a,name);
30    save(matfile,'a');
31    for i=1:nargin
32      a = varargin{i};
33      save([matfile '_' num2str(i)],'a');
34    end
35    for i=1:nargout
36      varargout{i} = varargin{i};
37    end
38  end
39end
Note: See TracBrowser for help on using the repository browser.