LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Performing calculations (using a complex formula) on data

I would like to use the following formula, Simpson's rule for a circle, on data I have collected.

Area= [Pi((R(n)+R(n+1))/2)^2]/360+[Pi((R(n+1)+R(n+2))/2)^2]/360+...

This is a summation formula where for each iteration, one point, R(n), is added to the succeeding point,R(n+1). Once all 360 points that I have collected from my data acquisition have gone through the equation, I can add up all the iterations to get cross sectional area.

Ok, now I need to figure out how to get LV 4.0 to use this equation. I initially thought I could use the formula node, but that won't work because all of my data is being auto indexed in a while loop, then put in an array.

I was thinking about adding the calculat
ion portion to the while loop, but I figured that would slow things down too much. Unfortunately, I don't know how to get LV to do the n and n+1 for all 360 points.

Please help! Attached in my current program.
0 Kudos
Message 1 of 2
(2,634 Views)
> I would like to use the following formula, Simpson's rule for a
> circle, on data I have collected.
>
> Area= [Pi((R(n)+R(n+1))/2)^2]/360+[Pi((R(n+1)+R(n+2))/2)^2]/360+...
>
....

> I was thinking about adding the calculation portion to the while loop,
> but I figured that would slow things down too much. Unfortunately, I
> don't know how to get LV to do the n and n+1 for all 360 points.
>

A simple option is to use a shift register. Popup on the
while loop and add a shift register. Either popup on the
left shift register to add a terminal or grow the left
terminal down. At this point, each value that is written
to the right edge will show up on the left, and the
previous will show up below giving you val_n and val_n-1.

There are many ways to finish
this, but initializing the
terminals to something like NaN and testing for two non-
NaN values inside the loop or testing i will prime the
shift registers.

Another option is to turn off auto-indexing and use one
or more index nodes to peel off the n and n+1 items.

I'm not sure what it means to add the calculation portion
to the while loop. If this means using individual plus
and multiply nodes, I wouldn't worry much about the speed.
The formula node and individual icons generate similar
code, especially when the debugging info is turned off in
VI Info.

Greg McKaskle
0 Kudos
Message 2 of 2
(2,634 Views)