Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

Topic: sorting dates with corresponding strings data
Replies: 2   Last Post: Aug 4, 2013 12:56 AM

Advanced Search

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

Posts: 20
Registered: 3/10/11
sorting dates with corresponding strings data
Posted: Aug 3, 2013 11:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

hello, I need to sort dates and need to have string data be sorted along with it's corresponding date. I don't think I can use chars because the text data are not all the same length and don't think I can use cells since I can not include cells in a rowsort(x,[1]) function. Someone must know how to do this and I will be most grateful for any help.

Here is what I have been working with:
x=datenum(2008,08,05)
y=datenum(2007,07,04)
z=datenum(2006,02,03)

xyz={datestr(y);datestr(x);datestr(z)} % matlab will sort this
% c=char('tim','clare','sin')% no, char arrays are sensative to length of the word
% c={'tim';'clare';'sin'} % no, can't row sort a cell
xyzc=[xyz,c] %
rowsort(xyzc,[1]) %i can't get this to work


Thank you,
larry



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.