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
- ethylene_glycol_section.txt
Freezing and Boiling Points of Heat Transfer Fluid; Wt% Ethylene Glycol;FreezingPoint °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 26.0;11.4 27.0;10.4 28.0;9.2 29.0;8.0 30.0;6.7 35.0;-0.2 40.0;-8.1 45.0;-17.5 50.0;-28.9 55.0;-42.0 60.0;-54.9
supp/excel_for_scientists/interpolation.1448539062.txt.gz · Last modified: 2015/11/26 11:57 by admin