3 %>@brief Convex Polygonal Line baseline correction
5 %> This was inspired on OPUS Rubberband baseline correction (RBBC) [1].
7 %> Stretches a convex polygonal line whose vertices touch troughs of x
8 %> without crossing x (see below).
10 %> This one is parameterless, whereas OPUS RBBC asks
for a number of points.
12 %> @image html rubberlike_explain.png
14 %> <h3>References</h3>
15 %> [1] Bruker Optik GmbH, OPUS 5 Reference Manual. Ettlingen: Bruker, 2004.
17 %> @sa demo_pre_bc_rubber.m
19 %> @param X [@ref no]x[@ref nf] matrix whose rows will be individually baseline-corrected
21 %> @
return @em [Y] or @em [Y, L] Where @em L are the baselines
24 msgstring = nargoutchk(1, 2, nargout);
25 if ~isempty(msgstring)
60 %---------------------------------------------------------------------
61 % returns a
"rubber" vector with one element less than the length of x
62 function y = rubber(x)
64 nf = length(x); % number of points
66 l = linspace(x(1), x(end), nf);
69 [val, idx] = min(xflat);
70 if ~isempty(val) && val < 0
71 y = [rubber(x(1:idx)), rubber(x(idx:end))];