From: William on 8 Jul 2010 02:56 A problem working with a time series. I have a vector of dates (imaginatively titled 'dates'), more or less covering all business days over a time period of a few years. I use the date series as inputs to a dialog box, for the user to choose start and end dates that define a desired subset. (So far so good.) Rather than scroll through a couple of thousand dates in the list, I'd like to convert 'dates' into a list of months, so the user-defined subset will cover whole months. Finally, once that's done, I need to map the user-defined subset back onto the original list of dates. That is, given a start month of mm/yyyy, I then want the earliest date in 'dates' falling in that month (which may or may not be the 1st day of the month), and likewise find the last day in the list that falls within the end month. Does anyone have some thoughts on how to approach this?
From: dpb on 8 Jul 2010 08:52 William wrote: > A problem working with a time series. I have a vector of dates > (imaginatively titled 'dates'), more or less covering all business days > over a time period of a few years. I use the date series as inputs to a > dialog box, for the user to choose start and end dates that define a > desired subset. (So far so good.) > > Rather than scroll through a couple of thousand dates in the list, I'd > like to convert 'dates' into a list of months, so the user-defined > subset will cover whole months. > Finally, once that's done, I need to map the user-defined subset back > onto the original list of dates. That is, given a start month of > mm/yyyy, I then want the earliest date in 'dates' falling in that month > (which may or may not be the 1st day of the month), and likewise find > the last day in the list that falls within the end month. > > Does anyone have some thoughts on how to approach this? doc datenum doc datestr for starters. It's essentially taking the array, converting to datenum's, finding min/max, returning those to string representation for the UI then doing similar on those values and selecting the data within that range. Toolbox(es) of various types have some functions built to do the month stuff automagically; in base ML you'll need to compute the individual month start/stop datenums but it's pretty smart in "adding one" in the conversion as described in the doc's. --
From: Ashish Uthama on 8 Jul 2010 09:12 On Thu, 08 Jul 2010 02:56:06 -0400, William <billytea69(a)yahoo.com> wrote: > A problem working with a time series. I have a vector of dates > (imaginatively titled 'dates'), more or less covering all business days > over a time period of a few years. I use the date series as inputs to a > dialog box, for the user to choose start and end dates that define a > desired subset. (So far so good.) > > Rather than scroll through a couple of thousand dates in the list, I'd > like to convert 'dates' into a list of months, so the user-defined > subset will cover whole months. Finally, once that's done, I need to map > the user-defined subset back onto the original list of dates. That is, > given a start month of mm/yyyy, I then want the earliest date in 'dates' > falling in that month (which may or may not be the 1st day of the > month), and likewise find the last day in the list that falls within the > end month. > > Does anyone have some thoughts on how to approach this? If you know the range of your series, why not have a 'date picker'? Say a couple of drop down boxed to specify the start/end month and year. Convert these mm/yyyy to 01/mm/yyyy. You might have to increment the end mm/yyyy smartly to start of the next month. Then, you can convert your 'dates' into numbers using DATENUM and using >/< to find the range selected.
|
Pages: 1 Prev: hsv image quantization Next: Number of wavelet coefficients in each level of decomposition |