03-05-2023 12:46 AM
I am doing this for quite some time and I am not able to come up with the solution. Why does not it show the sum of random numbers ? It always show zero. I have seen one similar question on the NI community.
03-05-2023 07:11 AM
The Sum of Random Numbers is placed outside of the loop. The value will only be updated once you press the Stop button and exit the loop. To update the value in real-time, place the summation and indicator inside the loop.
03-05-2023 09:44 AM
As has been said, you need to understand the basics of dataflow. Data is only available once the previous structure has completed, i.e. the while loop in this case. Have you looked at some of the tutorials?
I would also stay far away from resized shift registers, they make the code clumsy and not scalable. For example if your teacher wants you to average the last 5000 random elements in tomorrows problem, you would need to start from scratch. Proper scalable code would only need to change one integer.
Other problems in your code:
For some ideas about implementing a running average, have a look at my 2016 NI week presentation (Part II).
03-05-2023 09:52 AM
Here is a simple example how you would sum all random numbers using only a few bytes of constant memory. Be careful, [i] will overflow after a while if the loop runs too fast.