LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to limit size of an array?

Solved!
Go to solution

I want to build an array of a certain size by loops stopping when the array is full. I have to use a for loop and not use Boolean logic. I feel there's a connection to be made with the iteration count and count terminal but can't quite figure it out.

0 Kudos
Message 1 of 36
(1,876 Views)

@User002 wrote:

I want to build an array of a certain size by loops stopping when the array is full. I have to use a for loop and not use Boolean logic. I feel there's a connection to be made with the iteration count and count terminal but can't quite figure it out.


Sounds like a homework assignment.  Unfortunately I don't have LV 2020 installed on this computer.  Would you mind saving for previous as LV 2018 so I can see what you have?

 

Thanks.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 36
(1,865 Views)

Not exactly. I realized I only knew one way of doing it and felt really limited. 

0 Kudos
Message 3 of 36
(1,857 Views)

You're generating random numbers and you only want to keep them if they fall in a certain range. It's not possible to know how many random numbers you'll need in order to hit your desired array size.

 

Maybe take a step back and explain what you're trying to do, and we can suggest a better way to do it.

 

Capture.PNG

0 Kudos
Message 4 of 36
(1,856 Views)

@Gregory wrote:

You're generating random numbers and you only want to keep them if they fall in a certain range. It's not possible to know how many random numbers you'll need in order to hit your desired array size.

 

Maybe take a step back and explain what you're trying to do, and we can suggest a better way to do it.

 

Capture.PNG


That's why it seemed like homework to me.  The constraints were so artificial that they sounded like a homework exercise.  Yes, I agree that we need a better explanation of what the VI needs to do.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 36
(1,844 Views)
  • Since you don't know the number of iterations needed. a FOR loop is incorrect. Why do you "have to use one"? (homework?)
  • What do you or don't you know about boolean logic? Why can't you use boolean logic? (homework?)
  • Why all these silly restrictions???? (homework?)
  • Do you know how to stop a while loop?
  • Do you know how to get the current size of an array?
  • How would you compare it with the desired final size? 
  • Why is the array orange if all your number are integers? Try blue instead!
  • Your random number generation is not fair because the edge values (0 and 100) only occur with half the probability of the other numbers. Try to improve that or you'll never get a job in Las Vegas!

 

 

0 Kudos
Message 6 of 36
(1,833 Views)

This is not homework. Majority was copied from homework about loops because it was a quick copy paste. I just wanted to see if I could build an array using the for loop. 

0 Kudos
Message 7 of 36
(1,814 Views)

@User002 wrote:

 I just wanted to see if I could build an array using the for loop. 


 

Yes you can. For example, you could place an inner while loop that tries over and over until a matching random number is found before the FOR loop can go to the next iteration.

0 Kudos
Message 8 of 36
(1,810 Views)

So there's no way to determine the size of the array you want to build before it's built? I can't say the array's limit is 10 elements, for example, and then just "fill it up" with data? This is my first week with labVIEW, so I'm a little confused

0 Kudos
Message 9 of 36
(1,781 Views)

@User002 wrote:

So there's no way to determine the size of the array you want to build before it's built? I can't say the array's limit is 10 elements, for example, and then just "fill it up" with data? This is my first week with labVIEW, so I'm a little confused


I don't understand the whole "limit" thing.  Instead of creating an egg carton and filling it with eggs, why can't you just have a box of unlimited size and put twelve eggs in it?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 36
(1,769 Views)