Results 1 to 2 of 2

Math Help - Matlab Date Sorting Program, need help

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    3

    Matlab Date Sorting Program, need help

    Hello, I'm currently trying to write a program which sorts birth dates imported from a text file, in descending order. The data is imported into a matrix of 100 rows and 3 columns; column 1 being the year(yyyy), column 2 being the month(mm), and column 3 being the day(dd). I am able to sort any of the 3 and reference the location of each element so I can swap the rows of each column, but I'm unable to figure out the problem of also sorting the other two columns without screwing up the order of the first. My main issue is that once I get the Year column sorted, the Month and Day columns follow their location just fine, but on elements of the same year, the month and day order are not in proper descending order.

    Ex:

    Year Month Day
    2006 02 05
    2006 02 11
    2002 05 19
    2000 02 18
    2000 12 25
    2000 10 12
    etc...
    Last edited by aPexDrifta; April 27th 2010 at 06:26 PM. Reason: The spacing did not show up correctly for the 'table'
    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 aPexDrifta View Post
    Hello, I'm currently trying to write a program which sorts birth dates imported from a text file, in descending order. The data is imported into a matrix of 100 rows and 3 columns; column 1 being the year(yyyy), column 2 being the month(mm), and column 3 being the day(dd). I am able to sort any of the 3 and reference the location of each element so I can swap the rows of each column, but I'm unable to figure out the problem of also sorting the other two columns without screwing up the order of the first. My main issue is that once I get the Year column sorted, the Month and Day columns follow their location just fine, but on elements of the same year, the month and day order are not in proper descending order.

    Ex:

    Year Month Day
    2006 02 05
    2006 02 11
    2002 05 19
    2000 02 18
    2000 12 25
    2000 10 12
    etc...
    Form a composite variable:

    ZZZ=dd+100*mm+10000*yyyy;

    where dd is the day, mm the month and yyyy the year, now sort on ZZZ

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Writing a program in MATLAB
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 13th 2011, 06:08 AM
  2. Help with my MATLAB DJ program?
    Posted in the Math Software Forum
    Replies: 6
    Last Post: May 3rd 2010, 07:20 AM
  3. Sorting the all array in MATLAB
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 13th 2010, 11:53 AM
  4. Converting an R-program to MATLAB
    Posted in the Math Software Forum
    Replies: 0
    Last Post: November 17th 2009, 07:54 AM
  5. MATLAB program creation help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: November 7th 2009, 07:53 PM

Search Tags


/mathhelpforum @mathhelpforum