nextpow2

Purpose

Next power of two.

Synopsis

p = nextpow2(n)
p = nextpow2(x)

Description

p = nextpow2(n) returns the first p such that 2^p >= abs(n). It is often useful for finding the nearest power of two sequence length for FFT operations.

p = nextpow2(x), where x is a vector, is nextpow2(length(x)).

Examples

For any integer n in the range from 513 to 1024, nextpow2(n) is 10.

See Also

fft, log2, pow2

(c) Copyright 1994 by The MathWorks, Inc.