1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA - Farid BELAHCENE
3 // Copyright (C) DIGITEO - 2011 - Allan CORNET
5 // This file must be used under the terms of the CeCILL.
6 // This source file is licensed as described in the file COPYING, which
7 // you should have received as part of this distribution. The terms
8 // are also available at
9 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11 function y = flipdim(x, dim)
14 // Given x, a scalar/vector/matix of reals and an integer dim, this function flips the x components along the dimension number dim (x and y have the same size).
16 // x : a scalar/vector/array of reals
17 // dim : a positive integer
19 // y : a scalar/vector/array of reals
25 error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"flipdim", 2));
28 if size(dim,"*")<>1 then
29 error(msprintf(gettext("%s: Wrong size for input argument #%d: A positive integer expected.\n"),"flipdim",2));
30 elseif type(dim)<>8 & (type(dim)<>1 | dim<1) then
31 error(msprintf(gettext("%s: Wrong type for input argument #%d: A positive integer expected.\n"),"flipdim",2));
34 if ndims(x)==2 & type(x)<>1 then
35 error(msprintf(gettext("%s: Wrong value for input argument #%d: Real matrix expected.\n"),"flipdim",1));
36 elseif ndims(x)>2 & type(x.entries)<>1
37 error(msprintf(gettext("%s: Wrong value for input argument #%d: Real matrix expected.\n"),"flipdim",1));
52 for k = dim + 1:ndims(x)