![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sorting data from who by IP | raidzero | UNIX for Dummies Questions & Answers | 11 | 06-19-2008 09:56 AM |
| Sorting your data with msort | iBot | UNIX and Linux RSS News | 0 | 05-19-2008 11:20 AM |
| Date Sorting | LiquidChild | Shell Programming and Scripting | 14 | 05-29-2007 07:34 AM |
| date sorting | nmilella | UNIX for Dummies Questions & Answers | 3 | 07-11-2006 04:11 AM |
| sorting on date | Duckman | UNIX for Dummies Questions & Answers | 6 | 03-29-2001 04:32 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Matlab (more generally: sorting data by date)
I'm not sure if this really belongs anywhere on this forum but my previous experiences on here have shown me that you guys are very helpful so I figure I may as well try.
I have a bunch of large 2d arrays in matlab and each has a column for a date that each row corresponds to. The format is yymmdd except for everything for 2000 which is just mmdd. I need to be able to separate the data based on season (ie DJF, MAM, JJA, SON) but I'm not sure what is the best way to go about it based on the format of the data. I could write a bunch of if statements to decide each season but the 2000 data complicates that method. Any advice (you don't have to write anything out) would be much appreciated. It's been a few years since my last programming class and I can't remember the best practice for this. ![]() |
|
||||
|
All you care about is the mm part.
Programatically I would transform the date column in the array, to a 'season value' before doing any sorting. Create a vector (assuming zero based) S with 12 elements s[0..2] == 0 (Spring), s[3..5] == 1 (Summer) and so on. For each row in your array, get the mm substring from the date. Convert the mm to an integer say i, replace the date value in the column with s[i]. Use a length(column) to see if the year 2000 problem exists. If you sort numerically on the transformed date column, you get seasonal order. You can also preserve the date by adding another column to the array, transforming into it, then sorting. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|