Ask Your Question
2

interpolate missing values

asked 2012-03-09 14:56:34 +0200

yecril71pl gravatar image yecril71pl
36 1 4

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?

delete close flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2012-03-09 17:35:37 +0200

yecril71pl gravatar image yecril71pl
36 1 4

updated 2012-03-09 17:36:16 +0200

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
link delete flag offensive edit

Comments

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.
yecril71pl ( 2012-03-09 17:36:34 +0200 )edit

How do you use this?

endolith ( 2013-01-23 16:39:39 +0200 )edit

Login/Signup to Answer

Donate

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!

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-03-09 14:56:34 +0200

Seen: 432 times

Last updated: Mar 09 '12