Matlab (more generally: sorting data by date)

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Matlab (more generally: sorting data by date)
# 1  
Old 06-22-2009
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. Smilie
# 2  
Old 06-22-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Plz Help in sorting the data on date basis

I have file a.txt having below data cat a.txt 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493... (5 Replies)
Discussion started by: ranabhavish
5 Replies

2. UNIX for Dummies Questions & Answers

Plz Help in sorting the data on date basis

I have file having below data 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493 01-JUL-13... (2 Replies)
Discussion started by: ranabhavish
2 Replies

3. Shell Programming and Scripting

Sorting data file by date and time

Hello. Sorting data file by date and time with the following issues: Date is in the following format m/d/yyyy, no leading zeros Time is in the following format h:m:s AM/PM, no leading zeros Any ideas on how to sort data when the above issues? Could the date/time be converted inline to... (5 Replies)
Discussion started by: JimBurns
5 Replies

4. Shell Programming and Scripting

Sorting by date

I am trying to sort by two columns. The first column in an ID, the second is a date in the form yyyy-mm-dd. I need to sort by the ID column, then in ascending order for the date column (earliest date to most recent date compared to today). Input data: 012-abc 2012-04-25 ... (3 Replies)
Discussion started by: mollydog11
3 Replies

5. Shell Programming and Scripting

Sorting the data with date

Hi, PFB the data: C_Random_130417 Java_Random_130518 Perl_Random_120519 Perl_Random_120528 so the values are ending with year,i.e.,130417 i want to sort the values with date. i want the output like this: Perl_Random_120519 Perl_Random_120528 C_Random_130417 Java_Random_130518 can... (5 Replies)
Discussion started by: arindam guha
5 Replies

6. UNIX and Linux Applications

Importing data's from cadence to MATLAB

hello, debashish here. i am working with 6 bit flash ADC design. So for calculation of INL and DNL ,i have to import data from cadence to MATLAB . Can anybody help me out:confused: (1 Reply)
Discussion started by: DEBASHISH DASH
1 Replies

7. Shell Programming and Scripting

Date Sorting

Hi, I have a list of files that take on the format ABCDE_yymmdd and wish to sort them in ascending date order. I can't use the unix time stamp for the file as this could possibly be different from the date given in the file name. Does anyone know of any way this can be done using unix shell... (14 Replies)
Discussion started by: LiquidChild
14 Replies

8. Shell Programming and Scripting

Sorting a date coulumn

Hi All, I have a file say abc.txt with the below data. 1234 876S 01Mar2007 foo 1244 65DF 19Jan2007 boo 9924 234K 01Jan2006 koo 8866 8FGH 12Feb1999 roo 7777 ASDF 13May2007 soo I need this file to be in sorted order depending on the date field. e.g 8866 8FGH 12Feb1999 roo... (2 Replies)
Discussion started by: rinku11
2 Replies

9. UNIX for Dummies Questions & Answers

date sorting

Hi at all, I have to sort a log file on timestamp field. That's field is the third! a log file sample..... 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:23|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:16|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:20|0.3.8... (3 Replies)
Discussion started by: nmilella
3 Replies

10. UNIX for Dummies Questions & Answers

sorting on date

I have a file where dates in the form mm/dd/yyyy is the first field. How do I sort the file by the date field? Thanks, Duckman (6 Replies)
Discussion started by: Duckman
6 Replies
Login or Register to Ask a Question