1 ## Copyright (C) 2008 Michel D. Schmid <michaelschmid@users.sourceforge.net>
4 ## This program is free software; you can redistribute it and/or modify it
5 ## under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
9 ## This program is distributed in the hope that it will be useful, but
10 ## WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ## General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; see the file COPYING. If not, see
16 ## <http://www.gnu.org/licenses/>.
19 ## @deftypefn {Function File} {} @var{retmatrix} = __copycoltopos1(@var{matrix},@var{colIndex})
20 ## @code{__copycoltopos1} copies the column of position colIndex to the first position.
21 ## Moves the rest of the matrix one position to the right.
26 function retmatrix = __copycoltopos1(matrix,colIndex)
28 ## check number of inputs
29 error(nargchk(2,2,nargin));
31 temp = matrix(:,colIndex);
32 matrix(:,colIndex) = []; # delete col
33 retmatrix = [temp matrix ];
38 %! disp("testing __copycoltopos1")
39 %! a = [0 1 2 3 4; 5 6 7 8 9];
40 %! retmat = __copycoltopos1(a,3);
41 %!assert(retmat(1,1)==2);
42 %!assert(retmat(2,1)==7);
43 %! retmat = __copycoltopos1(a,5);
44 %!assert(retmat(1,1)==4);
45 %!assert(retmat(2,1)==9);