]> Creatis software - CreaPhase.git/blob - octave_packages/nnet-0.1.13/__copycoltopos1.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nnet-0.1.13 / __copycoltopos1.m
1 ## Copyright (C) 2008 Michel D. Schmid  <michaelschmid@users.sourceforge.net>
2 ##
3 ##
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)
7 ## any later version.
8 ##
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.
13 ##
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/>.
17
18 ## -*- texinfo -*-
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.
22 ## @end deftypefn
23
24 ## Author: mds
25
26 function retmatrix = __copycoltopos1(matrix,colIndex)
27
28   ## check number of inputs
29   error(nargchk(2,2,nargin));
30
31   temp = matrix(:,colIndex);
32   matrix(:,colIndex) = []; # delete col
33   retmatrix = [temp matrix ];
34
35 endfunction
36
37 %!shared a, retmat
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);