From: fraser5002 on 4 Mar 2010 17:21 Hi i want to extract all non zero rows from a matrix how do i do this? My Matrix has 5 cols and roughly 20 rows a row will either have all 5 cols non zero or all 5 cols zeros . How do i make a copy if the array only extracting the non zero rows to make for example a 2 x 5 matrix Thanks
From: Jos (10584) on 5 Mar 2010 04:22 fraser5002 <fraser.dickson(a)selexgalileo.com> wrote in message <1197132806.320576.1267777303691.JavaMail.root(a)gallium.mathforum.org>... > Hi i want to extract all non zero rows from a matrix how do i do this? > > My Matrix has 5 cols and roughly 20 rows > > a row will either have all 5 cols non zero or all 5 cols zeros . > > How do i make a copy if the array only extracting the non zero rows to make for example a 2 x 5 matrix > > Thanks Learn about logical indexing: MyMatrix = [0 0 1 ; 0 0 0 ; 1 2 3 ; 0 0 0] TF = MyMatrix==0 TFrow = ~all(TF,2) MyMatrix(TFrow,:) Jos
|
Pages: 1 Prev: Goodness of fit Next: reading 100 images using single imread command |