Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating area under a curve

37 views
Skip to first unread message

Scot Middleton

unread,
Aug 16, 1997, 3:00:00 AM8/16/97
to

I want to calculate area under a curve using the trapezoidal rule and a
series of x,y data points. Sigmaplot has a transform to do this, but it
seems that a macro could accomplish this in Exel using the built-in
functions. I just can't figure out how!
Anyone got the answer?

John REDMAYNE

unread,
Aug 18, 1997, 3:00:00 AM8/18/97
to

Scot,

This UDF should do the trick.

Function TrapArea(x As Object, y As Object) As Variant

Dim i As Integer
Dim N As Integer
' Count the number of passed x values
N = Application.Count(x)
' Check that we have the same number of y's
If Application.Count(y) <> N Then
TrapArea = "Unequal input arrays"
Else
TrapArea = 0
For i = 1 To N - 1
' Integrate using trapezium rule .....
TrapArea = TrapArea + ((y(i) + y(i + 1)) / 2) * (x(i + 1) - x(i))
Next i
End If

End Function

--
Yours aye,

John Redmayne
NATO


Scot Middleton <sc...@adnetsol.com> wrote in article
<eey5ubo...@uppssnewspub05.moswest.msn.net>...

Hans Knudsen

unread,
Aug 18, 1997, 3:00:00 AM8/18/97
to

Hello
I have made a small Excel model doing just that (+ Simpson
approximation).
Please drop me a note if you want a copy of the file.

Regards

Hans Knudsen

0 new messages