LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

numeric integration with variable division/integration interval

I want to calculate the area under a certain curve (data read from a spreadsheet file) by doing a numeric integration. The problem is that the interval between two adjacent points progressively changes from the start to end. I think I can get away with it by using a for loop. But is there a simpler way to do that. Thanks!
0 Kudos
Message 1 of 7
(2,613 Views)
A for loop should be fine. Each pair of points from the curve defines a trapezoidal area which can be easily calculated and summed. If the two points are (Xi,Yi) and (Xi-1,Yi-1), then the area defined by those points and the points on the X-axis (Xi,0) and (Xi-1,0) is given by 0.5*(Yi-1-Yi)*(Xi-1-Xi). It is irrelevant whether delta X varies from one interval to the next.

Use shift registers to access previous values and to keep a running sum.

Lynn
0 Kudos
Message 2 of 7
(2,604 Views)
No need to use a for loop. You can calculate the area under the curve by direct calculations on the X and Y arrays. The method is not very accurate since it relies on the trapeze formula, but should work if your data points are not too distants. See the attached vi.

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 3 of 7
(2,599 Views)
Thanks, CC.

I had not thought of the direct approach.

Lynn
0 Kudos
Message 4 of 7
(2,590 Views)

johnsold wrote:...I had not thought of the direct approach.
Not sure that it is really a better solution, since it uses twice the memory amount used with the FOR loop method. But it should be more rapid.

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 5 of 7
(2,586 Views)
Thanks, Lynn and CC. CC, could you give me the code in labview 7.0 or 6.1. I don't have labview 7.1. Thanks!

Kui
0 Kudos
Message 6 of 7
(2,579 Views)
Kui,

Here's CC's VI in version 7.0 (attached).

Regards,
John
0 Kudos
Message 7 of 7
(2,573 Views)