I am looking for something like
nextpow2 in MATLAB like this:
P = nextpow2(A)returns the exponents for the smallest powers of two that satisfy $2^P\geq\left|A\right|$.
How about this?
The same thing in a different style:
You have a good answer already, but I'll mention the following since it may be useful in the future.
Many built-in functions are written in MATLAB and can be viewed, in this case
Not exactly the same, but very closely related is
When is it not equivalent to