0

I having this number generator from value 4 to 4.999 each time, I wan to make it into 2 index array such as each time the number generates the first number will store in the first index array, while the second number will store in the second index array, then the third number will store back into the first index array and repeat continuously. So lastly I able to ramp the higher value in the array index to the lower value of array index and display in numbers of samples.

I have a vi here: https://i.stack.imgur.com/902X7.png which I don't what was the correct placement. Anyone can provide me any advices?

Please let me know if you don't understand my question..

Royal DeviLz
  • 15
  • 3
  • 12
  • Please clarify what you want to achieve, and how your code doesn't achieve it. Do you want to generate two separate arrays, or an array with two copies of each random number as shown in your code? If you want two copies of each value, do you want these in two columns of a two-dimensional array instead of consecutive locations of a one-dimensional array? Could you post an example table showing how the result should look? I don't understand the sentence 'So lastly I able to ramp the higher value in the array index to the lower value of array index and display in numbers of samples' at all. – nekomatic Sep 15 '14 at 09:47
  • By the way, the random numbers generated by your code will range from 4 to 4.9 each time, not 4.999. – nekomatic Sep 15 '14 at 09:47

1 Answers1

0

Regardless of whether you're placing data in two separate arrays or just interleaving the data, you could perform a modulo operation to swap the index or the array. Wire the Loop iteration terminal of your loop to the Quotient & Remainder function, and divide by two. Every time the remainder is zero, your index is an even number, every time it's 1, it's an odd number. You can use those results directly as the index if you're using a single, two dimensional array, or you can use it to select between two different arrays by either using a case structure, or by converting the result into a boolean value and using it as the input to a Select function.

Ryan Duell
  • 182
  • 6