取消
显示结果 
搜索替代 
您的意思是: 

Labview and random numbers

已解决!
转到解答

Hallo,

I have a task on labview about a company of water who fills bottles.So I use a tank that I want to be filled from 285ml (min) to 315ml (max). I have to use random numbers(dice) in a while loop .Every time a random number enters I multiply it with 500 so that I have bigger chance to get in the prefered range.But the numbers my dices give me are the most time out of the (285-315 range).What can I do to make my dice give me numbers close to 285-315 in order to have less errors.

0 项奖励
1 条消息(共 11 条)
2,514 次查看
解答
已被主题作者 Dennis99 接受

Use the Random Number (Range).vi

 

rndumber.png

 

If you have an older version without that vi this should do about the same thing:

rnd2.png

========================
=== Engineer Ambiguously ===
========================
2 条消息(共 11 条)
2,501 次查看

With the way you were doing it the value would only be correct about 6% of the time (315-285=30, 30/500=0.06). A little basic Algebra I is all that you need to make your random number scale to be within this range 100% of the time. The random number generator is scaled from 0 to 1 so you need to make your value 285 when the random number is 0 and 315 when it is 1. I'm not going to do this homework problem for you. If you can't figure it out from there on your own perhaps you should pursue a different course of study.

0 项奖励
3 条消息(共 11 条)
2,498 次查看
0 项奖励
4 条消息(共 11 条)
2,450 次查看

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 项奖励
5 条消息(共 11 条)
2,385 次查看

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁

0 项奖励
6 条消息(共 11 条)
2,372 次查看

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".

========================
=== Engineer Ambiguously ===
========================
0 项奖励
7 条消息(共 11 条)
2,353 次查看

@RTSLVU wrote:

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".


Yes, it was specific to using random numbers and sometimes a picture is worth a thousand words. 🏆

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 项奖励
8 条消息(共 11 条)
2,347 次查看

@Dennis99 wrote:

What can I do to make my dice give me numbers close to 285-315 in order to have less errors.


Well, we are not really sure what "close to" means. Do you want every single random number in this range or do you want the occasional reject to be detected and rejected? For example if the tank is empty, you might get a bottle with 0ml. 😄

0 项奖励
9 条消息(共 11 条)
2,340 次查看

@Frozen wrote:

@RTSLVU wrote:

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".


Yes, it was specific to using random numbers and sometimes a picture is worth a thousand words. 🏆


Perhaps I was a bit harsh. As soon as I saw random numbers I assumed homework, and that he was in a tech profession that would require a lot of basic Algebra. My daughter has just completed Algebra I so I saw a lot of problems like this. I had hoped that I had described the solution well enough in words to get there. Altenbach did bring up a valid point, though. We all assumed "close to" meant that he really wanted all of the values to be in the range, but perhaps some were to be rejected. 

0 项奖励
10 条消息(共 11 条)
2,329 次查看