#1   Report Post  
Ruud
 
Posts: n/a
Default combine 2 curves

I have two curves. the curves are specified in a table ca 100 points.
I like to add or substract these tables (curves).
Both have nearly the same number of points but the specified points do not
match.
I need to do interpolation between the values of two points to get macthes
to calculated with. No idear how I can do this
can someone help

  #2   Report Post  
Art
 
Posts: n/a
Default

This may not be what you want -- it uses VBA.

Assume that one curve is in columns B and C, the other curve is in E and F.
Also assume that the curves start in row 2. The x-values are B and E, the
y-vlaues in C and F. Also assume that B and E are in increasing order.

Try the following macro (but save your sheet first, it will insert rows)

Option Explicit
Public LastRow As Integer

Sub MatchupCurves()
Dim rIndex As Integer
Dim MoreData As Boolean

MoreData = True
rIndex = 2
While MoreData
If Cells(rIndex, 2) Cells(rIndex, 5) And Cells(rIndex, 5) < "" Then
Range(Cells(rIndex, 2), Cells(rIndex, 3)).Insert shift:=xlDown
Cells(rIndex, 2) = Cells(rIndex, 5)
End If
If Cells(rIndex, 5) Cells(rIndex, 2) And Cells(rIndex, 2) < "" Then
Range(Cells(rIndex, 5), Cells(rIndex, 6)).Insert shift:=xlDown
Cells(rIndex, 5) = Cells(rIndex, 2)
End If
rIndex = rIndex + 1
If Cells(rIndex, 2) = "" And Cells(rIndex, 5) = "" Then MoreData = False
LastRow = rIndex - 1
Wend
End Sub

Sub Interpolate()
Dim mColumn As Integer
Dim mRow As Integer
Dim i As Integer
Dim temp As Double

For mColumn = 2 To 5 Step 3
For mRow = 2 To LastRow
If Cells(mRow, mColumn) = "" Then Exit For
If Cells(mRow, mColumn + 1) = "" Then
i = mRow + 1
While Cells(i, mColumn + 1) = ""
i = i + 1
Wend
temp = Cells(mRow, mColumn) - Cells(mRow - 1, mColumn)
temp = temp / (Cells(i, mColumn) - Cells(mRow - 1, mColumn))
Cells(mRow, mColumn + 1) = temp * (Cells(i, mColumn + 1) -
Cells(mRow - 1, mColumn + 1)) + Cells(mRow - 1, mColumn + 1)
End If
Next mRow
Next mColumn
End Sub

Run MatchupCurves and then run Interpolate. This won't do the adding, I'm
guessing you can handle that. This also will not do any extrapolating. That
is, if the endpoints do not coincide there's nothing to interpolate with.

I tested this on a few examples, but not exhuastively. Good Luck.

Art
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to combine multiple files in ms excel fifi Excel Discussion (Misc queries) 1 January 12th 05 12:11 PM
combine the text or digit in different cells hande Excel Discussion (Misc queries) 1 January 6th 05 03:44 PM
how do i combine columns in excel psamiam Excel Discussion (Misc queries) 2 December 6th 04 08:19 AM
how to combine several tabs on a spreadsheet into a summary tab w. adeeb Excel Discussion (Misc queries) 2 December 5th 04 10:49 AM
Combine Mutiple Worksheets into one Dean F Excel Discussion (Misc queries) 11 November 27th 04 05:18 PM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"