LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate and Array of N intgeres then divide it

Hello, I have this task :
Generate a string consisting of N random integers between 1 and 1000.
Then separate the string into 5 other substrings, consisting of:
Substring 1 – all numbers in the string divisible by 3
Substring 2 – all numbers in the string divisible by 5
Substring 3 – all numbers in the string divisible by 6
Substring 4 – all numbers in the divisible string

All i manage to do is this, but i don;t know how to divide it and after i have to introduce it into the table. 

0 Kudos
Message 1 of 7
(1,049 Views)
  • Integers are blue, not orange.
  • Rounding to nearest makes the random numbers unfair (edge values only have half the probability and you get an illegal value (zero) with some probability. You'll never get a job in Las Vegas!)
  • You don't have any strings or substring anywhere. Are you talking about the table? Are you talking about sub-arrays?
  • All you need is one loop, right?
  • What is the "divisible string"? I am not familiar with that term.
  • "Divide" is a mathematical operation. You are probably talking about separating into various arrays (have a look at the conditional autoindexing output tunnels, for a simple solution)
0 Kudos
Message 2 of 7
(1,034 Views)

What i need is to know how to get the elements of an array that are divisible/divided by 3 (%3, for labview VI), and put them into another array.

0 Kudos
Message 3 of 7
(1,030 Views)

You cannot divide strings, but quotient&remainder will give a remainder of zero if the number is divisible.

 

Maybe this can give you some ideas.

 

altenbach_0-1685386699852.png

 

 

As I said, you can have conditional output tunnels for each desired divisibility. I recommend to go back to the learning resources.

 

 

 

Message 4 of 7
(1,004 Views)

Thank you for your help. My question is, despite what i did (let's forget it), is: "How do i take numbers from 1D array, divide them by three, and if the remainder is 0, put them in another array"
That's what i want to know. The thing about strings and that table is that, after i see if and element is divisible by that number, i have to introduce it into the table. What i want to know is the first question.

0 Kudos
Message 5 of 7
(979 Views)

@ShadowRise wrote:

Thank you for your help. My question is, despite what i did (let's forget it), is: "How do i take numbers from 1D array, divide them by three, and if the remainder is 0, put them in another array"


Did you click my earlier link about conditional tunnels? Was there anything not clear? If you auto index your number at an output tunnels and make that conditional, you'll get a 1D array of only the elements where the condition is true. Once you understand that, the rest will fall into place. Good luck!

 


@ShadowRise wrote:

That's what i want to know. The thing about strings and that table is that, after i see if and element is divisible by that number, i have to introduce it into the table. What i want to know is the first question.


Once you have all your special 1D arrays (one for each divisibility), you can format them into strings and build/transpose them into a 2D array suitable for the table indicator (keep in mind that 2D array cannot be ragged, so all rows/columns will be padded to the longest with empty string elements.

Message 6 of 7
(971 Views)

I read it and now it works, thank you very much. I will post my solution later.

0 Kudos
Message 7 of 7
(959 Views)