LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing an accumulator ?

Hello

I was wondering about implementing a basic accumulator in Labview :

<text code>
c=0;
d=1.2;
for i =1:n
  c=c+d;
  ...
  ...
end
</text code>

Yes, I know I could do the above with a c=0+i*d, but I was curious about how to do it this way in G. Essentially, one would need to create a local variable that can be set self-referentially. The local variable definition available from the functions palette does not seem to fit the bill.


Message 1 of 2
(4,126 Views)
Just use a shift register.  Right click on the edge of your for loop and select "insert shift register".  Wire a "0" to the outside (left side) of the shift register.  Inside the for loop add the shift register (internal left side) to your "d" value and wire the result to the internal right side shift register.  The final result can be obtained from wiring to the (outside) right shift reigitster.
Message 2 of 2
(4,110 Views)