Skip to content
magiccpp1 edited this page Apr 19, 2015 · 3 revisions

this program merges data files, each data file contains number of (x,y) pairs. this program sums up y values from all files. if a x value is in file 1 but not in file 2, this program calculates the y value for file 2 using interpolation algorithm.

the number of input files is up to 8.

i.e. file data1_1.dat:

1.2 5.0

2.3 3.5

3.8 3.0

file dataset1_2.dat:

0.8 2.0

1.5 3.0

2.5 4.0

output:

0.8 0.0 2.0 # contribution from 1st array is 0, it is out of x range, from 2nd is 2.0

1.2 5.0 7.57 #5.0 + 2.0 + (1.2-0.8) * (3.0-2.0)/(1.5-0.8) contribution from 1st array is 5.0, from 2nd is 2.57

1.5 4.6 7.6 #3.0 + 5.0 + (1.5 - 1.2) * (3.5 - 5.0) / (2.3 - 1.2) contribution from 1st array is 4.6, 2nd is 3.0

2.3 ...

2.5 ...

3.8 3.0 0.0 #contribution from 2nd array is 0, it is out of x range.

Author : Ken Dai

Email: xiaodong.ken.dai@gmail.com

Clone this wiki locally