Rev | Line | |
---|
[137] | 1 | %PR_SAVEMATFILE Save matfile(s) for calling mfile
|
---|
| 2 |
|
---|
| 3 | function 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 |
|
---|
| 9 | name = pr_callername;
|
---|
| 10 | matfile = fullfile(fullfile(fileparts(which(name)),'data'),name);
|
---|
| 11 |
|
---|
| 12 | varargout = cell(1,nargout);
|
---|
| 13 | if nargin == 1
|
---|
| 14 | a = varargin{1};
|
---|
| 15 | save(matfile,'a');
|
---|
| 16 | varargout{1} = a;
|
---|
| 17 | else
|
---|
| 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
|
---|
| 39 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.