LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculate integral, rectangle method

Solved!
Go to solution

I would like to calculate the integral of a function (I have the array with the values), with the rectangle method. How can I do?

alternatively, being dt = 1, I could calculate the sum of all the elements of the array, but with the for loop it is too slow.

How could I do? Thanks,

S.

0 Kudos
Message 1 of 5
(817 Views)

hi,

you could use the following function (from the mathematic palette) :

 

Emna20_0-1652708723007.png

 

0 Kudos
Message 2 of 5
(812 Views)
Solution
Accepted by nept

Hi nept,

 


@nept wrote:

I could calculate the sum of all the elements of the array, but with the for loop it is too slow.


Why do you need a FOR loop to calculate the sum of an array? (Ever heard of ArraySum function?)

And what exactly means "too slow"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(808 Views)

thanks, I did not know the function "add array elements"

0 Kudos
Message 4 of 5
(791 Views)

If "add array elements" is fast enough, it is unlikely that using a FOR loop is too slow unless you are doing something terribly wrong (are you for example pumping the sum across iterations with value property nodes???). FOR loops (and shift register) are one of the most efficient structures. Can you show us what you did to make things "too slow" so we can help you improve your LabVIEW skills?

 

I seriously doubt that you would notice a performance difference between the following two version:

 

altenbach_0-1653326147630.png

 

0 Kudos
Message 5 of 5
(718 Views)