1 | %LOADMATFILE Load matfile for this mfile, if it exist
|
---|
2 | %
|
---|
3 | % A = LOADMATFILE(MATFILE)
|
---|
4 | %
|
---|
5 | % Loads the dataset stored in the matfile. Default matfile is the name of
|
---|
6 | % the calling routine.
|
---|
7 | %
|
---|
8 | % [A1,A2,..] = LOADMATFILE(MATFILE,NARGOUTCOUNT)
|
---|
9 | %
|
---|
10 | % In case multiple matfiles are stored for the calling routine, it is
|
---|
11 | % assumed they all contain a dataset: train set, test set, validation set,
|
---|
12 | % etcetera. In case NARGOUTCOUNT (NARGOUT of the calling routine) equals 1,
|
---|
13 | % the combined dataset is loaded and returned in A (A1).
|
---|
14 | % In case NARGOUTCOUNT > 1, the subsets are are loaded into A1, A2, ...
|
---|
15 | %
|
---|
16 | % SEE ALSO
|
---|
17 | % DATASETS, PRDATASETS, SAVEMATFILE, PR_DOWNLOAD_UCI
|
---|
18 |
|
---|
19 | function varargout = loadmatfile(name)
|
---|
20 |
|
---|
21 | varargout = cell(1,nargout);
|
---|
22 |
|
---|
23 | if nargin < 1 || isempty(name)
|
---|
24 | name = callername;
|
---|
25 | end
|
---|
26 | matfile = fullfile(fileparts(which(name)),name);
|
---|
27 |
|
---|
28 | if nargout == 1
|
---|
29 | varargout{1} = loadmatf([matfile '.mat']);
|
---|
30 | else
|
---|
31 | for i=1:nargout
|
---|
32 | varargout{i} = loadmatf([matfile '_' num2str(i) '.mat']);
|
---|
33 | end
|
---|
34 | end
|
---|
35 |
|
---|
36 | return
|
---|
37 |
|
---|
38 | function a = loadmatf(matfile)
|
---|
39 | if exist(matfile,'file') == 2
|
---|
40 | s = load(matfile);
|
---|
41 | fields = fieldnames(s);
|
---|
42 | a = getfield(s,fields{1});
|
---|
43 | else
|
---|
44 | a = [];
|
---|
45 | end
|
---|
46 | return
|
---|
47 |
|
---|
48 | function name = callername
|
---|
49 | [ss,dummy] = dbstack;
|
---|
50 | if length(ss) < 3
|
---|
51 | name = [];
|
---|
52 | else
|
---|
53 | name = ss(3).name;
|
---|
54 | end
|
---|
55 | return |
---|