43 error (
"%s: dimension vector DIMS must not be empty", name);
51 if (ii == dimsv(i) && ii >= 0)
55 error (
"%s: dimension vector DIMS must contain integers", name);
66 @deftypefn {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{i}, @var{j})\n\
67 @deftypefnx {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{s1}, @var{s2}, @dots{}, @var{sN})\n\
68 Convert subscripts to a linear index.\n\
70 The following example shows how to convert the two-dimensional\n\
71 index @code{(2,3)} of a 3-by-3 matrix to a linear index. The matrix\n\
72 is linearly indexed moving from one column to next, filling up\n\
73 all rows in each column.\n\
77 linear_index = sub2ind ([3, 3], 2, 3)\n\
84 int nargin = args.length ();
96 dv = dv.
redim (nargin - 1);
97 for (
int j = 0; j < nargin - 1; j++)
99 if (args(j+1).is_numeric_type ())
101 idxa(j) = args(j+1).index_vector ();
104 else if (j > 0 && args(j+1).dims () != args(1).dims ())
105 error (
"sub2ind: all subscripts must be of the same size");
108 error (
"sub2ind: subscripts must be numeric");
172 @deftypefn {Function File} {[@var{s1}, @var{s2}, @dots{}, @var{sN}] =} ind2sub (@var{dims}, @var{ind})\n\
173 Convert a linear index to subscripts.\n\
175 The following example shows how to convert the linear index @code{8}\n\
176 in a 3-by-3 matrix into a subscript. The matrix is linearly indexed\n\
177 moving from one column to next, filling up all rows in each column.\n\
181 [r, c] = ind2sub ([3, 3], 8)\n\
189 int nargin = args.length ();
200 if (nargout > dv.
length ())
201 dv = dv.
redim (nargout);