+ Reply to Thread
Results 1 to 2 of 2

Integration/area under a curve VBA code?

  1. #1
    WayneL
    Guest

    Integration/area under a curve VBA code?

    Hi



    I have built a spreadsheet that can calculate the area under a curve of a
    set of data but I would like to have this in VBA for Excel, in say
    Integral(C1,C2) format or a button on the toolbar.

    Can anyone point me in the right direction for acquiring the code?



    Cheers



    WayneL



  2. #2
    WayneL
    Guest

    Re: Integration/area under a curve VBA code?

    Thanks Gregory Vainberg (http://www.vbnumericalmethods.com) for this perfect
    solution.

    I have tested it with FlexPro and the value correlates.

    Cheers

    WayneL



    Hey Wayne,

    I have a number of different methods that you can use, but the easiest
    technique is trapezoidal integration. On the website I have a version that
    takes the function name as a parameter, but it can be easily adapted to use
    2 vectors as parameters as follows:

    Public Function TRAPnumint(x, y) As Double

    n = Application.Count(x)

    TRAPnumint = 0

    For t = 2 To n

    TRAPnumint = TRAPnumint + 0.5 * (x(t) - x(t - 1)) * (y(t - 1) +
    y(t))

    Next

    End Function

    Where x is the column of x values and y is the column of f(x) values.

    Hope this helps,

    Gregory Vainberg

    http://www.vbnumericalmethods.com

    "WayneL" <[email protected]> wrote in message
    news:[email protected]...

    > Hi
    >
    >
    >
    > I have built a spreadsheet that can calculate the area under a curve of a
    > set of data but I would like to have this in VBA for Excel, in say
    > Integral(C1,C2) format or a button on the toolbar.
    >
    > Can anyone point me in the right direction for acquiring the code?
    >
    >
    >
    > Cheers
    >
    >
    >
    > WayneL
    >

    "WayneL" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    >
    >
    > I have built a spreadsheet that can calculate the area under a curve of a
    > set of data but I would like to have this in VBA for Excel, in say
    > Integral(C1,C2) format or a button on the toolbar.
    >
    > Can anyone point me in the right direction for acquiring the code?
    >
    >
    >
    > Cheers
    >
    >
    >
    > WayneL
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1