supp:excel_for_scientists:interpolation
This is an old revision of the document!
Table of Contents
Interpolation
Linear
VBA Function
Option Explicit ' Linear Interpolation function from the companion CD ' of the book "Excel for Scientists" by Billo. Function InterpolateL(lookup_value, known_xs, known_ys) Dim pointer As Integer Dim X0 As Double Dim Y0 As Double Dim X1 As Double Dim Y1 As Double 'Following line added to prevent extrapolation If lookup_value < Application.Min(known_xs) Or lookup_value > Application.Max(known_xs) Then InterpolateL = CVErr(xlErrRef): Exit Function End If pointer = Application.Match(lookup_value, known_xs, 1) X0 = known_xs(pointer) Y0 = known_ys(pointer) X1 = known_xs(pointer + 1) Y1 = known_ys(pointer + 1) InterpolateL = Y0 + (lookup_value - X0) * (Y1 - Y0) / (X1 - X0) End Function
Data
Freezing and Boiling Points of Heat Transfer Fluid Wt% Ethylene Glycol Freezing Point, °F 0.0 32.0 5.0 29.4 10.0 26.2 15.0 22.2 20.0 17.9 21.0 16.8 22.0 15.9 23.0 14.9 24.0 13.7 25.0 12.7 30.0 6.7 40.0 -8.1 50.0 -28.9 60.0 -54.9
supp/excel_for_scientists/interpolation.1448536224.txt.gz · Last modified: 2015/11/26 11:10 by admin