Resize x cutting off elements as necessary.
In the result, element with certain indices is equal to the corresponding element of x if the indices are within the bounds of x; otherwise, the element is set to zero.
In other words, the statement
y = resize (x, dv)
is equivalent to the following code:
y = zeros (dv, class (x)); sz = min (dv, size (x)); for i = 1:length (sz) idx{i} = 1:sz(i); endfor y(idx{:}) = x(idx{:});
but is performed more efficiently.
If only m is supplied, and it is a scalar, the dimension of the result is m-by-m. If m, n, … are all scalars, then the dimensions of the result are m-by-n-by-…. If given a vector as input, then the dimensions of the result are given by the elements of that vector.
An object can be resized to more dimensions than it has; in such case the missing dimensions are assumed to be 1. Resizing an object to fewer dimensions is not possible.
See also: reshape, postpad, prepad, cat.
Package: octave