ISUNIFORM

Purpose:

Returns 1 if the input values are uniformly spaced.

Syntax:

ISUNIFORM(series, tol)

(tf, stepsize) = ISUNIFORM(series, tol)

series

-

A real series. The input series to check.

tol

-

Optional. A real, the tolerance value. Defaults to 4*eps(max(abs(series)))

Returns:

An integer, 1 if the elements of the series are uniformly spaced up to round-off tolerance and 0 otherwise. If the input is a multi-column series, 0 or 1 is returned for each column.

 

(tf, stepsize) = ISUNIFORM(series) also returns stepsize, the constant step size. If series is uniformly spaced, stepsize is a scalar equal to the common step size. If series is not uniformly spaced, stepsize is NaN.

Example:

a = {1, 2, 3, 4};

b = {1, 1.5, 2, 3};

c = {10};

d = {10, 10};

 

isuniform(a) == 1

isuniform(b) == 0

isuniform(c) == 0

isuniform(d) == 1

 

If the input is a real-valued series containing at least two elements and each successive value increases by the same constant amount (including zero), the series is considered uniform.

Example:

v = 0..0.5..10;

(tf, stepsize) = isuniform(v);

 

tf == 1

stepsize == 0.5

 

Series v is uniform with a step size of 0.5.

 

Example:

v = 10..-0.5..0;

(tf, stepsize) = isuniform(v);

 

tf == 1

stepsize == -0.5

 

Series v is uniform with a step size of -0.5.

Example:

v = {1, 2, 4, 5};

(tf, stepsize) = isuniform(v);

 

tf == 0

stepsize == nan

 

Series v is not uniform.

Example:

a = linspace(0, 1, 100);

b = a;

b[end] = 5 * eps(max(abs(a)));

 

isuniform(a) == 1;

isuniform(b) == 0;

 

The perturbation of series b is exceeds the 4*eps default tolerance.

Example:

a = {1, nan, 2};

b = {1, 2, inf};

c = {nan, nan};

d = {inf, inf}

 

isuniform(a) == 0;

isuniform(b) == 0;

isuniform(c) == 0;

isuniform(d) == 0;

 

Any input series with nan or inf is not considered uniform.

Example:

a = 10;

b = "10";

c = {1 + 2i, 2 + 3i};

d = {10};

 

isuniform(a) == 0;

isuniform(b) == 0;

isuniform(c) == 0;

isuniform(d) == 0;

 

The input is not considered uniform if it is not a real series with at least two values.

Remarks:

ISUNIFORM returns 1 when the values of  series change by a constant step size.

 

If the input series is not uniform, the returned value is 0 and the returned stepsize is NaN.

 

ISUNIFORM returns 0 if the input is not a real series or length(SERIES) < 2.

 

A real series with length >= 2 and all equal values is considered uniform with a step size of 0.

See Also:

FINITE

ISEMPTY

ISINF

ISXY