Prev: Can you use MFC functions/libraries with s-functions and MEX compiler?
Next: how can i use matlab2007a in my windows 7 homebasic
From: Antonio Trujillo-Ortiz on 2 Jul 2010 02:16 Hi all, Suppose a matrix A with Nan's, such as: A=[1 2 Nan 4 5 Nan 8 NaN 3 6 7 10 7 3 4 3 NaN 6 NaN 8 NaN 8 NaN NaN NaN]; and we are interesting to arrange it according to the number of NaN's in rows to have, B=[NaN 8 NaN NaN NaN Nan 8 NaN 3 6 3 NaN 6 NaN 8 1 2 Nan 4 5 7 10 7 3 4]; As you can see. Row 1 with 4 NaN's, row 2 with 2, row 3 with 2, row 4 with 1, and row 5 (last) without NaN's. I would apprciate any hint on this. Thx
From: us on 2 Jul 2010 02:31 "Antonio Trujillo-Ortiz" <atrujo(a)uabc.edu.mx> wrote in message <i0k076$q50$1(a)fred.mathworks.com>... > Hi all, > > Suppose a matrix A with Nan's, such as: > > A=[1 2 Nan 4 5 > Nan 8 NaN 3 6 > 7 10 7 3 4 > 3 NaN 6 NaN 8 > NaN 8 NaN NaN NaN]; > > and we are interesting to arrange it according to the number of NaN's in rows to have, > > B=[NaN 8 NaN NaN NaN > Nan 8 NaN 3 6 > 3 NaN 6 NaN 8 > 1 2 Nan 4 5 > 7 10 7 3 4]; > > As you can see. Row 1 with 4 NaN's, row 2 with 2, row 3 with 2, row 4 with 1, and row 5 (last) without NaN's. > > I would apprciate any hint on this. > > Thx one of the many solutions m=[ 1 2 NaN 4 5 NaN 8 NaN 3 6 7 10 7 3 4 3 NaN 6 NaN 8 NaN 8 NaN NaN NaN ]; [sx,sx]=sort(sum(isnan(m),2),'descend'); r=m(sx,:) %{ % r = NaN 8 NaN NaN NaN NaN 8 NaN 3 6 3 NaN 6 NaN 8 1 2 NaN 4 5 7 10 7 3 4 %} us
From: Antonio Trujillo-Ortiz on 2 Jul 2010 02:49
Hi us, Thanks for your valuable help. |