[Numpy-discussion] Removing rows and columns of a matrix

Nils Wagner nwagner at mecha.uni-stuttgart.de
Mon Jul 28 06:40:14 CDT 2003


Hi all,

 How can I delete a column/row from a matrix.

In Matlab:

>> a=rand(4,4)

a =

    0.9501    0.8913    0.8214    0.9218
    0.2311    0.7621    0.4447    0.7382
    0.6068    0.4565    0.6154    0.1763
    0.4860    0.0185    0.7919    0.4057

use

>> a(:,2)=[]

a =

    0.9501    0.8214    0.9218
    0.2311    0.4447    0.7382
    0.6068    0.6154    0.1763
    0.4860    0.7919    0.4057

>> a(2,:)=[]

a =

    0.9501    0.8214    0.9218
    0.6068    0.6154    0.1763
    0.4860    0.7919    0.4057

>> 

Is there something similar in scipy, numpy or numarray ?

Any suggestion ?

Nils




More information about the Numpy-discussion mailing list