Ask Your Question
2

interpolate missing values [closed]

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

yecril71pl gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-15 15:04:38.277519

1 Answer

Sort by » oldest newest most voted
0

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

yecril71pl gravatar image

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

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

How do you use this?

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

Question Tools

Stats

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

Seen: 2,642 times

Last updated: Mar 09 '12