The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Shifting NaNs to top of matrix
Replies: 6   Last Post: Mar 25, 2013 6:49 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 25
Registered: 8/6/10
Shifting NaNs to top of matrix
Posted: Mar 21, 2013 10:09 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.