LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add 1D arrays and then divide to find an average array?

Hello All,

 

I have a 1D array that is being generated inside of a case. This array leads out of the case, and I want to be able to add it to the previous array created, which is why I have it in a For Loop. As you can see in the picture attached, I am trying to figure out how to correctly add the current array to the previous one, and once the for loop is done, divide the added array by the number of iterations (basically the number of arrays added). Would this give me the averaged array? I want to average the array so I can find the averaged Max of the array which is being filled in by a frequency sweep.

0 Kudos
Message 1 of 3
(2,845 Views)

No, it will not.

On the first iteration previous array is default, it is empty. When you add data, you kill it and again write empty array into node.

Do not add, if old array is empty.

0 Kudos
Message 2 of 3
(2,838 Views)

Thank you Alexander for getting back to me so quickly.

Yes, that was the problem I was getting a lot of.

I changed that part of the code to what is shown in the image attached, and I think it's working out well... still need to stress test to be sure.Adding Array Modified.PNG

0 Kudos
Message 3 of 3
(2,828 Views)