Skip to content

Commit f3fc112

Browse files
author
jaib1
committed
updated doc on inferParameters
1 parent 64c719e commit f3fc112

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

+exp/inferParameters.m

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
11
function parsStruct = inferParameters(expdef)
2-
%EXP.INFERPARAMETERS Infers the parameters required for experiment
3-
% Detailed explanation goes here
2+
%EXP.INFERPARAMETERS Infers the parameters defined in an exp def
3+
%
4+
% Inputs:
5+
% 'expdef': the "experiment definition" .m file from which the parameters
6+
% are inferred. This argument can be set as a string or function handle
7+
%
8+
% Outputs:
9+
% 'parsStruct': the inferred parameters, returned as a MATLAB struct
10+
%
11+
% Example:
12+
% parsStruct = exp.inferParameters([fileparts(which('addRigboxPaths'))...
13+
% '\signals\doc\examples\expdefs\...']);
14+
%
15+
% fh = @...
16+
% parsStruct = exp.inferParameters(fh)
17+
%
18+
% See also:
19+
%
20+
% todo: update example
421

5-
% create some signals just to pass to the definition function and track
6-
% which parameter names are used
7-
8-
if ischar(expdef) && file.exists(expdef)
9-
expdeffun = fileFunction(expdef);
10-
else
11-
expdeffun = expdef;
12-
expdef = which(func2str(expdef));
22+
try
23+
if ischar(expdef) && file.exists(expdef) % if 'expdef' is a string
24+
expdeffun = fileFunction(expdef);
25+
else % if 'expdef' is a function handle
26+
expdeffun = expdef;
27+
expdef = which(func2str(expdef));
28+
end
29+
catch ex
30+
error(['Input argument must be a string of the full filename,'...
31+
'or a function handle']);
1332
end
1433

34+
% create some signals just to pass to the exp def and track which parameter
35+
% names are used
1536
e = sig.void;
1637
pars = sig.void(true);
1738
audio.Devices = @dummyDev;
1839

40+
% try to call the exp def file get the parameters defined in the file
1941
try
2042
expdeffun(e.t, e.events, pars, e.visual, e.inputs, e.outputs, audio);
21-
22-
% paramNames will be the strings corresponding to the fields of pars
23-
% that the user tried to reference in her expdeffun.
2443
parsStruct = pars.Subscripts;
2544

2645
% Check for reserved fieldnames

0 commit comments

Comments
 (0)