|Jun 10, 2012, 12:46 PM||#1|
Create a Calender matrix
Hi all, I have a quick question. I have gridded data I am trying to manipulate and for the sake of existing code I have written (that had this type of index with the data embedded in the netcdf file) would like to create an auxillary matrix with the corresponding time
For instance, I have 12,xxx indexes that correspond to each day between Jan 1, 1979 to Dec 31, 2011
I would like to create a 4x12,xxx array that is of the following behavior
(Record, Month, Day, Year) where each one is 12,xxx in length
Record is the raw index value (1-12,xxx)
Month is the coressponding month of the index value (ie 31 consecutive 1's for Janurary, 28 consecutive 2s for Feb, etc and repeats)
Day is the corresponding day (1-28(31)) for the index
Year is the corresponding year (365 consecutive 1979, then 365 1980s, etc)
Is there an easy way to make this type of array? I would need to take into accoun the leap years and what not
Thanks for any tips
|Jun 10, 2012, 01:09 PM||#2|
I'd start by figuring out how to convert the index into the appropriate NSTimeInterval value, then I'd use the NSDate and NSDateComponents classes to help me figure out the information I'm looking for. Read the documentation for more information on these classes, particularly the "Date and Time Programming Guide" - it gives you the answer in a section titled "Converting between Dates and Date Components."
MBP, MB, mini, PB G4(x2), eMac, ...
|Jun 10, 2012, 01:10 PM||#3|
1. Which language?
2. The intended meaning of "12,xxx" is unclear (though it might be clearer if we knew which language). Do you mean "approximately 12 thousand (~12,000, ~12k, ~12e3)" since the number of days in your date range is approximately 12 thousand (12,053)? Or do you mean "twelve" and the ",xxx" has some additional meaning? Or do you mean something else?
|Jun 10, 2012, 01:14 PM||#5|
I am creating the array in matlab. The 12,xxx is more explicitly 12,053 values
here is how I initially approached the problem.
%% Calender maker record = [1:1:12053]; y79 = [1:1:365]; y80 = [1:1:366]; y81 = [1:1:365]; y82 = [1:1:365]; y83 = [1:1:365]; y84 = [1:1:366]; y85 = [1:1:365]; y86 = [1:1:365]; y87 = [1:1:365]; y88 = [1:1:366]; y89 = [1:1:365]; y90 = [1:1:365]; y91 = [1:1:365]; y92 = [1:1:366]; y93 = [1:1:365]; y94 = [1:1:365]; y95 = [1:1:365]; y96 = [1:1:366]; y97 = [1:1:365]; y98 = [1:1:365]; y99 = [1:1:365]; y00 = [1:1:366]; y01 = [1:1:365]; y02 = [1:1:365]; y03 = [1:1:365]; y04 = [1:1:366]; y05 = [1:1:365]; y06 = [1:1:365]; y07 = [1:1:365]; y08 = [1:1:366]; y09 = [1:1:365]; y10 = [1:1:365]; y11 = [1:1:365]; day = [y79,y80,y81,y82,y83,y84,y85,y86,y87,y88,y89,y90,y91,y92... y93,y94,y95,y96,y97,y98,y99,y00,y01,y02,y03,y04,y05,y06,... y07,y08,y09,y10,y11]';
Edit: Figured it out...even though my code to generate it is not the most elagant!
Last edited by dukebound85; Jun 10, 2012 at 02:24 PM.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|I like the new Calender changes but.....||marlman||iOS 7||1||Mar 11, 2014 10:15 AM|
|iPhone: Jailbreak Matrix||smorris79||Jailbreaks and iOS Hacks||2||Dec 20, 2013 06:33 AM|
|Calender and Mail changes?||dannys1||OS X Mavericks (10.9)||1||Aug 25, 2013 04:06 PM|
|Calender invitations||Drich290195||iOS 6||0||Nov 19, 2012 07:05 AM|
|Lost calender!||Kelbelle||iPhone Tips, Help and Troubleshooting||1||Jun 26, 2012 05:31 PM|
All times are GMT -5. The time now is 12:02 PM.