1 ## Copyright (C) 2008 Bill Denney <bill@denney.ws>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {@var{hhv} =} hhigh (@var{data})
18 ## @deftypefnx {Function File} {@var{hhv} =} hhigh (@var{data}, @var{nperiods})
19 ## @deftypefnx {Function File} {@var{hhv} =} hhigh (@var{data}, @var{nperiods}, @var{dim})
21 ## Compute the highest high value of @var{data} for the past
22 ## @var{nperiods} (default: 14) across the dimension, @var{dim}
28 function hhv = hhigh (data, nperiods = 14, dim = find (size (data) > 1, 1))
30 if nargin < 1 || nargin > 3
32 elseif ! isvector (data)
34 error ("cannot yet handle more than one dimensional data")
38 error ("dim cannot be greater than the number of dimensions in data");
44 hhv(i) = max (data(max (i-nperiods+1, 1):i));
51 %! c = [22.44 22.61 22.67 22.88 23.36 23.23 23.08 22.86 23.17 23.69 23.77 23.84 24.32 24.8 24.16 24.1 23.37 23.61 23.21 25];
52 %! h = [22.44 22.61 22.67 22.88 23.36 23.36 23.36 23.36 23.36 23.69 23.77 23.84 24.32 24.8 24.8 24.8 24.8 24.8 24.8 25];
54 %!assert(hhigh(c'), h')