Chris Beaumont's IDL Library

Download source code

single page | use frames     summary     class     fields     routine details     file attributes




result = arrgen(first, last, step [, log=log] [, nstep=nstep])

This function is similar to (and an extension of) built-in functions like indgen, findgen, etc. It creates an array given the first element, last element, and step size. It can create arrays which increase/decrease by constant amounts at each element, or that increase/decrease by constant factors at each element.

Return value

The created array.


first in required

The first element in the array. The data type of the result will be the same as first

last in required

The (approximate) last element in the array. If there are not an integer number of elements between first and last, then one extra element will be added. In other words, either the last element will have the value "last", or the last two elements will bracket the value "last."

step in required

The difference between adjacent array elements. If /LOG is not set, this must be a positive number, and specifies the additive offset between adjacent elements. If /LOG is set, this must be a number greater than one. It specifies the multiplicative offset between adjacent elements.


log in optional

If set, then the array values increase or decrease by a multiplicative (instead of additive) constant at each step. In otherwords, the logarithm of the elements are evenly spaced.

nstep in optional

Set to specifiy the number of elements in the array, instead of the step size. This overrides step.


IDL> print, arrgen(1, 5, 1) 1 2 3 4 5 IDL> print, arrgen(1, 10, 4) 1 5 9 13 IDL> print, arrgen(5, 1, 2) 5 3 1 IDL> print, arrgen(1, 1000, 10, /log) 1 10 100 1000 IDL> print, arrgen(1.0D, 5, 1) 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000

Author information


July 2009: Written by Chris Beaumont July 2009: Added nstep keyword

File attributes

Modifcation date: Mon Mar 22 16:17:13 2010
Lines: 110