www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/NextPowerof2ofDoubleIntegerValuesExample.m
%% Next Power of 2 of Double Integer Values %% % Define a vector of |double| integer values and calculate the exponents % for the next power of 2 higher than those values. a = [1 -2 3 -4 5 9 519]; p = nextpow2(a) %% % Calculate the positive next powers of 2. np2 = 2.^p %% % Preserve the sign of the original input values. np2.*sign(a)