-
Notifications
You must be signed in to change notification settings - Fork 0
/
mT_setUpParamVals.m
47 lines (34 loc) · 1.31 KB
/
mT_setUpParamVals.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function SetupVals = mT_setUpParamVals(Settings)
% Draw initial paramter values, and also produce fields descibing upper and
% lower bounds on the parameters.
% HISTORY
% Reviewed 2020
% Pick inital parameters
specs = {'InitialVals', 'LowerBound', 'PLB', 'UpperBound', 'PUB'};
optionalSpecs = {'PLB', 'PUB'};
for iSpec = 1 : length(specs)
% Some of the specs are optional
if ismember(specs{iSpec}, optionalSpecs)...
&& ~(isfield(Settings.Params, specs{iSpec}))
warning('PLB and PUB not specified.')
continue
end
SetupVals.(specs{iSpec}) = mT_createParamStruct(Settings, specs{iSpec});
end
end
function ParamStruct = mT_createParamStruct(Settings, field)
% Create a strcuture with a field for every parameter. The value is
% set to that specified in the requested field of 'Settings'.
% NOTE
% This functions calls the function in 'Settings.Params(iParam).(field)()'. If
% the function gives random results, the ParamStrcut produced will be
% different every run.
% INPUT
% Settings Standard settings strcut
% field The parameter values will be taken from calls to
% Settings.Params(iParam).(field)()
for iParam = 1 : length(Settings.Params)
ParamStruct.(Settings.Params(iParam).Name) = ...
Settings.Params(iParam).(field)();
end
end