ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding array values with previous value

Solved!
Go to solution

Hello,

I have a while loop in which i am getting 5000 samples (values) on each iteration of loop. i want to hold that samples and needs to add that 5000 values with new 5000 samples.

In simple words, i have 1D-array which is updating on each iteration. i just simply wants to add new array elements with previous one. So that on last iteration i get the summed 1D array with 5000 values.

Attached is the VI which i am trying to do. 

The problem is holding the previous value in the shift register as change its value with each iteration. 

Please anyone can help.

Thanks

0 Kudos
Message 1 of 4
(3,010 Views)
Solution
Accepted by topic author sundas

Why not post a VI? Now we need to recreate it...

 

Why not embed the image? Now we need to download, open and delete it.

avg.

You don't need a shift register and a feedback node. The serve the same purpose.

 

Commulative array values.png

 

Here's the same with a shift register on the main loop:

Commulative array values (shift refisters).png

 

The top shift register could be initialized with an empty array (preventing it to work as a buffer), or with a sized array of 0s (so the case can be removed).

0 Kudos
Message 2 of 4
(2,980 Views)

It is impossible to troubleshoot from a truncated picture, so please attach your code and answer some questions.

 

  • What is the purpose of the first FOR loop?
    • Why does it have two shift registers?
    • What is the size of the incoming array?
    • If it is 5k samples, why do you even need that loop?
    • What value is wired to N and how does it relate to the input sizes?
    • What output do you expect from it?
    • Almost seems like a concatenating tunnel would have about the same useless functionality.
  • What is the purpose of the second FOR loop?
    • Since it does not produce any output, why is it even there?
    • Why do you initialize with an array of size 4999 if the other array is presumably 5000? One point will get dropped!
  • What is outside the currently visible area?
    • Is there a top-level while loop?
    • Why don't you anchor the shift registers there!
  • Have you done any basic tutorials?
0 Kudos
Message 3 of 4
(2,944 Views)

Hi CARYA,

your solution just worked perfectly.

Thank you so much for your help.

0 Kudos
Message 4 of 4
(2,934 Views)