NCL Home > Documentation > Functions > Array creators

ispan

Creates an array of equally-spaced integer values.

Prototype

	function ispan (
		start  [1] : integer,  
		finish [1] : integer,  
		stride [1] : integer   
	)

	return_val [*] :  integer

Arguments

start

Value at which to start.

finish

Value at which to end.

stride

A stride value indicating the spacing of the integer values between start and finish.

Description

This function returns an array of integer values beginning at start and ending at finish. Each element will be separated by the value of stride. The stride must be positive, and start and finish can be any valid integers.

See Also

fspan

Examples

Example 1

   x = ispan (1,10,1)      ; "x" = (/1,2, ..., 10/) 
                           ; (10 values)
   y = ispan (-100,100,10) ; "y" = (/-100, -90, ..., 0, 10, ... 90, 100/)
                           ; (21 values)

Example 2

To generate a 1D float array, you can use NCL's implicit coercion by multiplying the ispan result by a float value:

   mlon = 128
   y = ispan (0,mlon-1,1)*1.  ; y = (/0.,1.,2., ..., 127./) (128 values)

   dlon = 360./mlon
   lon  = ispan(0,mlon-1,1)*dlon  ; lon = (/0, 2.8125, ... , 357.1875/)