1 ## Copyright (C) 2010 Mark Borgerding <mark@borgerding.net>
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{outdata} =} helintrlv (@var{data}, @var{col}, @var{ngrp},@var{stp})
18 ## @var{col}-by-@var{ngrp}.
19 ## @seealso{heldeintrlv}
22 function [outdata,outstate] = helintrlv(data,col,ngrp,stp,init_state)
24 if (nargin < 4 ||nargin>5)
25 error('usage : interlvd = helintrlv(data,col,ngrp,stp)');
28 if(~isscalar(col) || ~isscalar(ngrp))
29 error("col and ngrp must be integers");
32 if( col ~= floor(col)|| ngrp ~= floor(ngrp))
33 error("col and ngrp must be integers");
37 if ( isvector(data) && columns(data) > rows(data) )
45 error("The length of data must be equals to ngrp*col");
49 init_state = zeros(stp*col*(col-1)/2,s(2));
55 tmp = reshape( data(:,k) , ngrp, col );
56 instate = init_state(:,k);
59 curStepSize = (k1-1)*stp;
60 tmpCol= [instate(1:curStepSize) ;tmp(:,k1)];
61 tmp(:,k1) = tmpCol(1:ngrp);
62 outstateCol=[outstateCol;tmpCol(end+1-curStepSize:end)];
63 instate = instate(curStepSize+1:end);
65 outdata(:,k) = reshape(tmp.',s(1),1);
66 outstate = [outstate outstateCol];