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
startValue at which to start.
finishValue at which to end. Can be less than start.
strideA 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.
If finish is less than start, then the values will be reversed.
See Also
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. Or, in V5.2.0 or later, you can use span:
mlon = 128 y = ispan (0,mlon-1,1)*1. ; y = (/0.,1.,2., ..., 127./) (128 values) ; y = span (0,mlon-1,1.) ; y same as above dlon = 360./mlon lon = ispan(0,mlon-1,1)*dlon ; lon = (/0, 2.8125, ... , 357.1875/) ; lon = span(0,mlon-1,dlon) ; lon = (/0, 2.8125, ... , 357.1875/)