From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

moving average of 3 random numbers

Solved!
Go to solution

It is my first time using LabVIEW and I need some help.

  • I have to design VI that generates random number from 10-100
  • VI shows the last generated number and the moving average of the last 3 generated number on a waveform chart
  • If the average of the last 3 generated numbers is greater than 55, the LED should switch on.

I have made the whole VI but I have problem with the first two loops. In the first loop the moving average should show the random number itself (((random number 1)+0+0)/1). In the second loop (((random number 1)+(random number 2)+0)/2) and after that my VI functions properly. The moving average shows other values in first two loops (ex. random number 17.54, average 29.28). Probably I have to change something in the shift registers but I'm not quite sure how to do that. I need help to correct my VI for the first two loops. Thank you in advance.Untitled.png

0 Kudos
Message 1 of 6
(5,456 Views)

@blagoj.arsovski wrote:

It is my first time using LabVIEW and I need some help.

  • I have to design VI that generates random number from 10-100
  • VI shows the last generated number and the moving average of the last 3 generated number on a waveform chart
  • If the average of the last 3 generated numbers is greater than 55, the LED should switch on.

I have made the whole VI but I have problem with the first two loops. In the first loop the moving average should show the random number itself (((random number 1)+0+0)/1). In the second loop (((random number 1)+(random number 2)+0)/2) and after that my VI functions properly. The moving average shows other values in first two loops (ex. random number 17.54, average 29.28). Probably I have to change something in the shift registers but I'm not quite sure how to do that. I need help to correct my VI for the first two loops. Thank you in advance.Untitled.png

Your indicators cannot update until the loop finishes as you have that code.  Simply put them INSIDE the loop so they can update with each iteration.  Move the Mait Ms inside the loop too

 


"Should be" isn't "Is" -Jay
Message 2 of 6
(5,420 Views)

But I need to devide by 1 in the first loop because there is one random number generated and devide by 2 in the second loop because there is another random number generated and added to the first one. In this case the first generated number is devided by 3, then the sum of the first and second is devided by 3 and after that is ok. I should not devide by 3 in the first two loops. The division by 3 starts after the second loop.

0 Kudos
Message 3 of 6
(5,397 Views)
Solution
Accepted by topic author blagoj.arsovski

Capture.PNG

easy

 

no explin it for the grade

 

Of course there are other ways

Example_VI.png


"Should be" isn't "Is" -Jay
Message 4 of 6
(5,388 Views)

Thank you sir. That way is much better.

0 Kudos
Message 5 of 6
(5,357 Views)

@blagoj.arsovski wrote:

Thank you sir. That way is much better.


Now that you got the high grade on the assignment, make sure you understand what the functions are, where you can find them, and how the graph properties are set.  Its not "Learning" untill you do understand.


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(5,275 Views)