MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Iterpolation and Dates

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78416] Re: Iterpolation and Dates
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Sun, 1 Jul 2007 03:45:51 -0400 (EDT)
  • References: <f65a1c$92e$1@smc.vnet.net>

Change the dates to AbsoluteTimes

(M 6) In[5]:= Table[{Pause[0.1]; Date[], i^2.1}, {i, 10}]

(M 6) Out[5]= {{{2007, 6, 30, 10, 56, 19.904332},
  1}, {{2007, 6, 30, 10, 56, 20.004832},
  4.2870938501451725}, {{2007, 6, 30, 10, 56, 20.105421},
  10.04510856630514}, {{2007, 6, 30, 10, 56, 20.205931},
  18.37917367995256}, {{2007, 6, 30, 10, 56, 20.306481},
  29.36547357720048}, {{2007, 6, 30, 10, 56, 20.407055},
  43.06432315864736}, {{2007, 6, 30, 10, 56, 20.507556},
  59.52588815791429}, {{2007, 6, 30, 10, 56, 20.608099},
  78.79324245407466}, {{2007, 6, 30, 10, 56, 20.708577},
  100.90420610885693}, {{2007, 6, 30, 10, 56, 20.809262},
  125.89254117941675}}

Herearesomedatesandsomedata:

(M 6) In[7]:= dateData = {{{2007, 6, 30, 10, 56,
    19.904332`8.051522590987842}, 1},
     {{2007, 6, 30, 10, 56, 20.004832`8.05370989224274},
       4.2870938501451725}, {{2007, 6, 30, 10, 56,
         20.105421`8.055888155203142}, 10.04510856630514},
     {{2007, 6, 30, 10, 56, 20.205931`8.058053849314923},
       18.37917367995256}, {{2007, 6, 30, 10, 56,
         20.306481`8.060209652816468}, 29.36547357720048},
     {{2007, 6, 30, 10, 56, 20.407055`8.062355318674143},
       43.06432315864736}, {{2007, 6, 30, 10, 56,
         20.507556`8.064488889857818}, 59.52588815791429},
     {{2007, 6, 30, 10, 56, 20.608099`8.066612915712756},
       78.79324245407466}, {{2007, 6, 30, 10, 56,
         20.708577`8.068725240865835}, 100.90420610885693},
     {{2007, 6, 30, 10, 56, 20.809262`8.070831661945784},
       125.89254117941675}}

(M 6) Out[7]= {{{2007, 6, 30, 10, 56, 19.904332},
  1}, {{2007, 6, 30, 10, 56, 20.004832},
  4.2870938501451725}, {{2007, 6, 30, 10, 56, 20.105421},
  10.04510856630514}, {{2007, 6, 30, 10, 56, 20.205931},
  18.37917367995256}, {{2007, 6, 30, 10, 56, 20.306481},
  29.36547357720048}, {{2007, 6, 30, 10, 56, 20.407055},
  43.06432315864736}, {{2007, 6, 30, 10, 56, 20.507556},
  59.52588815791429}, {{2007, 6, 30, 10, 56, 20.608099},
  78.79324245407466}, {{2007, 6, 30, 10, 56, 20.708577},
  100.90420610885693}, {{2007, 6, 30, 10, 56, 20.809262},
  125.89254117941675}}

Change the dates to AbsoluteTimes

(M 6) In[6]:= AbsoluteTime[Date[]]

(M 6) Out[6]= 3.392189805215516\[CenterDot]10^9

(M 6) In[9]:= absoluteDateData = ({AbsoluteTime[#1[[1]]], #1[[2]]} & \
) /@ dateData

(M 6) Out[9]= {{3.392189779904332\[CenterDot]10^9,
  1}, {3.392189780004832\[CenterDot]10^9,
  4.2870938501451725}, {3.392189780105421\[CenterDot]10^9,
  10.04510856630514}, {3.392189780205931\[CenterDot]10^9,
  18.37917367995256}, {3.392189780306481\[CenterDot]10^9,
  29.36547357720048}, {3.392189780407055\[CenterDot]10^9,
  43.06432315864736}, {3.392189780507556\[CenterDot]10^9,
  59.52588815791429}, {3.392189780608099\[CenterDot]10^9,
  78.79324245407466}, {3.392189780708577\[CenterDot]10^9,
  100.90420610885693}, {3.392189780809262\[CenterDot]10^9,
  125.89254117941675}}

Now you can interpolate the result

(M 6) In[11]:= interpolatedAbsoluteDateData =
 Interpolation[absoluteDateData]

(M 6) Out[11]= \!\(\*
TagBox[
RowBox[{"InterpolatingFunction", "[", "]"}],
False,
Editable->False]\)

Hereisaplot:

(M 6) In[19]:= Plot[
 interpolatedAbsoluteDateData[x], {x, First[absoluteDateData][[1]],
     Last[absoluteDateData][[1]]}]

I hope this helps...

--David
A WorkLife FrameWork
http://scientificarts.com/worklife
Now compatible with Mathematica 6


On Jun 30, 6:07 am, "Flurchick, Kenneth M" <FLURCHI... at ecu.edu> wrote:
> Hello All,
> Can one geterate an Interpolation if the x coordinates are Dates?
> If so, can you suggest how.
> kenf




  • Prev by Date: Re: Re: search for an operator in an expression
  • Next by Date: Re: search for an operator in an expression
  • Previous by thread: Re: Iterpolation and Dates
  • Next by thread: Re: Iterpolation and Dates