hi, I am new to coding/programming. How do I write a macro to integrate a series of n data points using an unknown function y=f(x)?
criteria includes the following:
Show a button to run your macro
Assume there are ten x/y pairs in the spreadsheet, starting with the first x value in cell A1, and
the first y value in cell B1, and the remaining data points organized vertically downward, with all
x-values in column A and y values in column B.
The x-values are equidistant (h= 1,2,....,etc I'm guessing)
All x and y values are equal or larger than zero. There are no empty spreadsheet cells or
irregular entries (letters and such) among the data set.
To approximate the integral, calculate and sum the areas of rectangles of area A=yi * deltaX
where yi is the right hand boundary of each interval bounded by two x-values (see posted
pictures of algorithm). deltaX is the distance between two adjacent x-values.
Output the value of the integral via a message box after the integration
I started with the following:
Function Unknown(x)
y = f(x)
End Function
(new module)
Option Explicit
Sub Eurler()
'This sets the integration limit from 1 to 10
xi = 0
xf = 10
h = 0.1
'This is the number of caluclations it will run
a = (xf - xi) / h
End Sub
criteria includes the following:
Show a button to run your macro
Assume there are ten x/y pairs in the spreadsheet, starting with the first x value in cell A1, and
the first y value in cell B1, and the remaining data points organized vertically downward, with all
x-values in column A and y values in column B.
The x-values are equidistant (h= 1,2,....,etc I'm guessing)
All x and y values are equal or larger than zero. There are no empty spreadsheet cells or
irregular entries (letters and such) among the data set.
To approximate the integral, calculate and sum the areas of rectangles of area A=yi * deltaX
where yi is the right hand boundary of each interval bounded by two x-values (see posted
pictures of algorithm). deltaX is the distance between two adjacent x-values.
Output the value of the integral via a message box after the integration
I started with the following:
Function Unknown(x)
y = f(x)
End Function
(new module)
Option Explicit
Sub Eurler()
'This sets the integration limit from 1 to 10
xi = 0
xf = 10
h = 0.1
'This is the number of caluclations it will run
a = (xf - xi) / h
End Sub