cancel
Showing results for 
Search instead for 
Did you mean: 

calculate integral, rectangle method

SOLVED
nept
Member
Solved!

calculate integral, rectangle method

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.

4 REPLIES 4
Emna20
Active Participant

Re: calculate integral, rectangle method

Message contains an image

hi,

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

 

Emna20_0-1652708723007.png

 

GerdW
Knight of NI
Solution

Re: calculate integral, rectangle method

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
nept
Member

Re: calculate integral, rectangle method

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

altenbach
Knight of NI

Re: calculate integral, rectangle method

Message contains an image

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