Showing results for 
Search instead for 
Did you mean: 

How to generate a range of numbers?

I am new to Labview and was wondering how to do a simple task. I have a range of numbers which I would like to generate. On a programming language it would be something like I am given the starting number and the ending number and an interval. (ex. starting number is 8 and ending number is 16- so I will generate numbers in the following sequence- 8,10,12,14,16) How would I do this in Labview ? I was thinking of using the add function, but I dont know how to put it in a loop. I will be very grateful for any help...
0 Kudos
Message 1 of 6
Hi Confused Undergrad,
This is a good beginning labview project. Like in other programming languages something like this is best done in a loop, like maybe a for loop.  This is still true for labview.  Before you enter the loop you want to do some calculation on the start and ending value to decide how many loops and the create the array inside the loop.  I will attach picture of a vi that will make a sequence of numbers that increment by one. Hopefully it will help you get started.


Message Edited by BrianPack on 06-08-2006 05:27 PM

Message Edited by BrianPack on 06-08-2006 05:28 PM

0 Kudos
Message 2 of 6
I would do this with a For Loop.  I would multiply the loop index by the size of the increment (2 in your example) and add the offset (8 in your example).  You will have to do a little math to figure out how many elements you want so you can wire that result into the "N" terminal of the loop to set the number of iterations.  You will wire the result of the multipy and add (from inside the For loop) to the edge of the loop where it will automatically build an array for you.  There you have your numbers in an array.  Of course, you could use the result inside the loop to do whatever it is you need the range of numbers for, or there could be another loop downstream (downwire?) that uses the array of numbers later.  This could also be a subVI feeding the numbers to some other VI.  All that depends on what ou are using the numbers for.  All of this is pretty basic stuff, so you might want to work through some of the tutorials to learn more LabVIEW concepts.
0 Kudos
Message 3 of 6

Hi, there are many ways to do it, one way is to use a for loop, and use a shift register with the add function to generate the array, and storing it in an array, or plotting it.

I post an example



I hope this helps. Please let me know if you need more help

Benjamin C
Principal Systems Engineer // CLA // CLED
0 Kudos
Message 4 of 6

You can also use the Ramp Pattern function if it is available on your target.

Message 5 of 6

Wow.  Digging up 9 year old posts to add ideas to.  Smiley Wink


With only 2 posts, "Confused undergrad" might still be confused, but hopefully is no longer an undergrad.

Message 6 of 6