Results 1 to 3 of 3

Math Help - Sorting the all array in MATLAB

  1. #1
    Newbie
    Joined
    Mar 2010
    Posts
    11

    Sorting the all array in MATLAB

    Hey all, simple question if I may.

    I've got a simple 5X5 matrix that I want to sort all of the numbers of the array in an ascending order ( The first column will be the smallest numbers, the second column will contain the next numbers and so on ...)
    I've tried the 'sort' and 'sortrows' functions with no luck. It's only working for individual columns.

    Any ideas ?

    Thanks.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Geomorphologist View Post
    Hey all, simple question if I may.

    I've got a simple 5X5 matrix that I want to sort all of the numbers of the array in an ascending order ( The first column will be the smallest numbers, the second column will contain the next numbers and so on ...)
    I've tried the 'sort' and 'sortrows' functions with no luck. It's only working for individual columns.

    Any ideas ?

    Thanks.
    Code:
    xx=rand(3,3)
    sz=size(xx)
    
    xx=reshape(xx,1,sz(1)*sz(2))
    xx=sort(xx)
    xx=reshape(xx,sz(1),sz(2))
    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Mar 2010
    Posts
    11
    Thanks, working like a charm
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab Date Sorting Program, need help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 28th 2010, 12:51 AM
  2. Matlab - cell array
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 3rd 2010, 05:28 AM
  3. Matlab data cleaning - cell array to matrix problem
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 24th 2010, 09:08 AM
  4. Multiple array generation in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 29th 2009, 02:01 PM

Search Tags


/mathhelpforum @mathhelpforum