Thanks. Unfortunately I need the rest of the data to be in the same order.
"Loren Shure" <Loren.Shure@mathworks.com> wrote in message news:firstname.lastname@example.org... > > "ladidalimey" <email@example.com> wrote in message > news:dwE2t.91776$ZZ.firstname.lastname@example.org... >> Hi, >> >> I'm trying to do the following: >> >> Take this example matrix: >> >> test = [nan 1 nan 1 >> 1 1 1 1 >> nan 1 1 nan] >> >> I want to shift all the nans to the top of each column so there is only >> numerical data below, resulting in: >> >> [nan 1 nan nan >> nan 1 1 1 >> 1 1 1 1] >> >> Any ideas for a way of doing this without resorting to a loop? >> >> Thanks. >> >> L. >> >> >> > > You can use sort with the 'descend' option if you don't care how the > non-NaN values are sorted. > > > -- > --Loren > > http://blogs.mathworks.com/loren