2015-05-20 20 views
0

我有6分鐘的時間間隔收集現有數據。時間戳在列A中,相應的值在列B中。Excel中時間戳數據的自動插值

我想插入此數據以獲得按分鐘細分的分數,使用基本插值方法計算。所需輸出的樣本顯示在D和E列中。

有沒有一種方法可以自動執行此計算? enter image description here

+0

閱讀[如何提出一個很好的問題(HTTP://計算器。 com/help/how-to-ask)將會幫助你儘早得到答案。請記住,這不是一個代碼寫作服務,所以發佈你有什麼和我們可以幫助你解決它。 – FreeMan

+0

完全同意FreeMan。爲了鼓勵改進你的問題,有幾種方法可以應用公式,宏,但基本上我們需要知道你在找什麼。我還想知道20/05/2015 07:06 13218.30000和20/05/2015 07:12 13218.40000之間差距的數字不應該是20/05/2015 07:06 \t 13218.35000 20/05/2015 07: 07 \t 13218.40000 20/05/2015 07:08 \t 13218.45000 20/05/2015 07:09 \t 13218.50000 20/05/2015 07:10 \t 13218.55000 20/05/2015 07:12 \t 13218.40000 只是好奇關於它。 – EEM

+0

這與[此答案](http://stackoverflow.com/a/2824094/4288101)有關。這個想法是,你在日期和值的2x2網格上進行「預測」。你使用'OFFSET'和'MATCH'獲得網格。其他網站與公式審查包括[本](http://www.blueleafsoftware.com/Products/Dagra/LinearInterpolationExcel.php)和[本](http://www.mrexcel.com/forum/excel-questions/ 138021-內插之間-兩dates.html)。 Google是[此搜索]的朋友(https://www.google.com/search?q=excel+two+date+interpolation)。 –

回答

0

我寫了我自己的插值函數。它不是爲日期設計的,因此您需要修改參數。這對你來說可能是一個很好的起點。第一個參數是要插入的數據點。第二個參數是定義曲線的輸入數據的範圍。請注意,當數據點超出範圍時,返回值將是最近的數據點,而不是外推值。

Function interpolate(inp As Double, rng As Range) 
' written by: Todd Wegner 
' 
' inp --> the data point to interpolate 
' rng --> the range of original data 
' 
' early binding 
Dim i As Long, dim1 As Long 
Dim x1 As Double, x2 As Double, y1 As Double, y2 As Double 
Dim arr As Variant 
' 
' set array to the Range(rng) 
    arr = rng 
' 
' if the input is below the data bounds 
' use the first data point, DO NOT extrapolate 
    If inp < arr(1, 1) Then 
    interpolate = arr(1, 2) 
    Exit Function 
    End If 
' 
' get array upper bound 
    dim1 = UBound(arr) 
' 
' if the input is above the data bounds 
' use the last data point, DO NOT extrapolate 
    If inp > arr(dim1, 1) Then 
    interpolate = arr(dim1, 2) 
    Exit Function 
    End If 
' 
' inputs that lie within the data range get interpolated 
    i = 1 
    Do Until inp < arr(i, 1) 
    i = i + 1 
    Loop 
    x1 = arr(i - 1, 1) 
    x2 = arr(i, 1) 
    y1 = arr(i - 1, 2) 
    y2 = arr(i, 2) 
' 
' return 
    interpolate = (y2 - y1)/(x2 - x1) * (inp - x1) + y1 
' 
End Function 
2

你可以嘗試從E1充絨:

=PERCENTILE(B$1:B$7,PERCENTRANK(A$1:A$7,D1,30)) 

(假定值不減少)

+0

我不相信這適用於各種各樣的情況。我可以創建一些簡單的例子,它返回意想不到的輸出。可以使用的輸入數據(日期和值)是否有限制?例如:日期:'5/21,5/22,5/23',值:'10,8,18',輸入:'5/22',輸出:'10',它應該是'8'。在其他非精確匹配情況下也是錯誤的。 –

+0

感謝您添加條件。根據我的經驗,數據很少會朝一個方向發展,所以這個公式引起了我的不安。 –

+0

你說得對,澄清適用條件總是更好。從羣組中發佈的插值示例中,大多數是增加或減少的關係。如果您想應用於遞減關係,則可以使用與「1-PERCENTRANK」相同的公式 –