nextpow2
2 的更高次幂的指数
说明
示例
下一个双精度整数值的 2 次幂
定义一个 double
整数值向量,并计算下一个 2 次幂大于这些值的指数。
a = [1 -2 3 -4 5 9 519]; p = nextpow2(a)
p = 1×7
0 1 2 2 3 4 10
计算正的 2 的更高次幂。
np2 = 2.^p
np2 = 1×7
1 2 4 4 8 16 1024
保留原始输入值的符号。
np2.*sign(a)
ans = 1×7
1 -2 4 -4 8 16 1024
无符号整数值的 2 更高次幂
定义一个无符号整数向量,并计算 2 的更高次幂大于这些值的指数。
a = uint32([1020 4000 32700]); p = nextpow2(a)
p = 1x3 uint32 row vector
10 12 15
计算下一个大于 a
中值的 2 次幂。
2.^p
ans = 1x3 uint32 row vector
1024 4096 32768
带填充的优化 FFT
当信号长度不等于 2 的幂时,使用 nextpow2
函数可提升 fft
的性能。
创建包含 8191 个样本值的一维向量。
rng default;
x = rand([1,8191]);
计算 2 的更高次幂中大于 8191 的值。
p = nextpow2(8191); n = 2^p
n = 8192
将信号和 2 的更高次幂传递给 fft
函数。
y = fft(x,n);
输入参数
A
— 输入值
由实数组成的标量、向量、数组、表或时间表
输入值,指定为由任何数值类型的实数组成的标量、向量、数组、表或时间表。
示例: 15
示例: [-15.123 32.456 63.111]
示例: int16([-15 32 63])
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| table
| timetable
扩展功能
tall 数组
对行数太多而无法放入内存的数组进行计算。
此函数完全支持 tall 数组。有关详细信息,请参阅 tall 数组。
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
GPU 代码生成
使用 GPU Coder™ 为 NVIDIA® GPU 生成 CUDA® 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
GPU 数组
通过使用 Parallel Computing Toolbox™ 在图形处理单元 (GPU) 上运行来加快代码执行。
此函数完全支持 GPU 数组。有关详细信息,请参阅Run MATLAB Functions on a GPU (Parallel Computing Toolbox)。
分布式数组
使用 Parallel Computing Toolbox™ 在集群的组合内存中对大型数组进行分区。
此函数完全支持分布式数组。有关详细信息,请参阅Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox)。
版本历史记录
在 R2006a 之前推出R2023a: 直接对表和时间表执行计算
nextpow2
函数可以对表或时间表中的所有变量执行计算,而无需通过索引访问这些变量。所有变量都必须具有支持计算的数据类型。有关详细信息,请参阅Direct Calculations on Tables and Timetables。
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)