[Numpy-discussion] Matlab -> NumPy translation and indexing

Alan G Isaac aisaac@american....
Mon Mar 5 08:35:06 CST 2007

On 3/5/2007 2:13 PM, David Koch wrote: 
> - Given a matrix R, is there an equvialent to the Matlab 
> operation R(:,j) = [] (which removes column j and 
> "shrinks" the matrix? 

>>> help(numpy.delete)
Help on function delete in module numpy.lib.function_base:

delete(arr, obj, axis=None)
    Return a new array with sub-arrays along an axis deleted.

    Return a new array with the sub-arrays (i.e. rows or columns)
    deleted along the given axis as specified by obj

    obj may be a slice_object (s_[3:5:2]) or an integer
    or an array of integers indicated which sub-arrays to

    If axis is None, then ravel the array first.

    >>> arr = [[3,4,5],

    >>> delete(arr, 1, 1)
    >>> delete(arr, 1, 0)

Alan Isaac

More information about the Numpy-discussion mailing list