4 %> Grid Searc Parameter: auxiliary
class for Grid Searches.
5 %> I think
this is deprecated.
7 %> @attention Works in log base 10
12 %> name: name of a field in
'.obj'
14 %> Double vector (numeric) / cell of strings
16 %> If numeric, it is essential to be increasing.
18 %> =0. Indicates whether the ticks and axis label should be formatted to show log values
25 % Whether the possible values are numeric
31 if nargin >= 1 && ~isempty(name_)
35 if nargin >= 2 && ~isempty(values_)
39 if nargin >= 3 && ~isempty(flag_log_)
40 o.flag_log = flag_log_;
44 function z = get.flag_numeric(o)
45 z = isnumeric(o.values);
48 function z = get_ticklabels(o)
52 z = arrayfun(@(x) sprintf('%.3g', log10(x)), o.values, 'UniformOutput', 0);
54 z = arrayfun(@(x) sprintf('%.3g', x), o.values, 'UniformOutput', 0);
58 function z = get_label(o)
60 f = find(o.name == '.');
62 na = na(f(end)+1:end); % uses only after last dot
65 if o.flag_log && o.flag_numeric
66 z = sprintf('log_{10}(%s)
', na);
72 function z = get_value(o, idx)
81 function z = get_value_string(o, idx)
88 z = ['10^
', num2str(log10(z))];
95 function z = get_values_numeric(o)
97 z = 1:numel(o.values);
105 function z = get_legends(o)
106 a = o.get_ticklabels();
107 if o.flag_numeric && o.flag_log
108 x = cellfun(@(z) ['10^{
', z, '}
'], a, 'UniformOutput
', 0);
112 z = cellfun(@(x) sprintf('%s=%s
', o.name, x), x, 'UniformOutput
', 0);
117 function o = move_to(o, idx)
119 irerror('Cannot move, grid search parameter is not numeric!
');
126 newv = v-v(1)-(v(end)-v(1))/2+v(idx);
135 %> [1 3 5 7] around 2 --> [1 2.3333 3.6667 5]
137 function o = shrink_around(o, idx)
139 irerror('Cannot shrink, grid search parameter is not numeric!
');
141 ni = numel(o.values);
148 if idx > 1 && idx < ni
153 x1 = x2-(x3-x2); % values need to be increasing
159 oldspan = v(end)-v(1);
161 newv = (v-v(1))*newspan/oldspan+x1;
function replace_underscores(in s)