Assumptions:
- The table to interpolate is in sheet #5.
- The independent column is A and data start at row 2.
- The code below interpolates column D, change C& to interpolate another column.
- Change L& to put the results further to the right.
First time here? Check out the FAQ!
I have a four-column table where the 1st column is the independent variable. Each other column has several values missing. Can I ask Calc to interpolate them?
SUB INTERPOLATE
DIM FY&, S AS OBJECT, V#, PY&, FT#, DT#, PV#, T#, C&, L&
LET C& = &O3
SET S = THISCOMPONENT. SHEETS (&O4)
LET FY& = &O1
LET L& = C& + &O4
DO
REM @SCAN
LET FT# = S. GETCELLBYPOSITION (&O0, FY&). VALUE#
IF FT# = &O0 THEN EXIT DO
LET V# = S. GETCELLBYPOSITION (C&, FY&). VALUE#
IF V# THEN
REM ?HASTEMP Y
LET S. GETCELLBYPOSITION (L&, FY&). VALUE# = V#
IF PY& THEN
REM ?NOTFIRST Y
LET PV# = S. GETCELLBYPOSITION (C&, PY&). VALUE#
LET DT# = FT# - S. GETCELLBYPOSITION (&O0, PY&). VALUE#
LET PY& = PY& + &O1
DO WHILE PY& < FY&
REM @BLANKS
LET T# = FT# - S. GETCELLBYPOSITION (&O0, PY&). VALUE#
LET S. GETCELLBYPOSITION (L&, PY&). VALUE# = (PV# * T# + V# * (DT# - T#)) / DT#
LET PY& = PY& + &O1
LOOP
REM @BLANKS X
ELSE
REM ?NOTFIRST N
LET PY& = FY&
END IF
REM ?NOTFIRST
END IF
REM ?HASTEMP
LET FY& = FY& + &O1
LOOP
REM @SCAN X
MSGBOX FY&
END SUB
REM !INTERPOLATE X
Assumptions:
LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!
Asked: 2012-03-09 14:56:34 +0200
Seen: 432 times
Last updated: Mar 09 '12
date format bringing up incorrect date result
How to sort pivot table by data
How to create an XY plot with individual data points?
Paste into calc search mac does not work?
We have a spreadsheet that has a text box that cannot be edited in Calc but can be in Excel
Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.