力量,。^
元素能力
Syntax
描述
C =
提出的每个元素A
。^B
A
到corresponding powers inB
. The sizes ofA
和B
must be the same or becompatible.
If the sizes ofA
和B
are compatible, then the two arrays implicitly expand to match each other. For example, if one ofA
或者B
是标量,然后将标量与另一个数组的每个元素组合。同样,具有不同方向的向量(一个行矢量和一个列向量)隐式扩展以形成矩阵。
Examples
Square Each Element of Vector
查找每个矩阵元素的倒数
Create a matrix,A
,并取决于每个元素的倒数。
a = [1 2 3;4 5 6;7 8 9];c = a。^ - 1
C =3×31.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111
An inversion of the elements is not equal to the inverse of the matrix, which is instead writtenA^-1
或者INV(A)
.
行向量到列矢量的功率
Create a 1-by-2 row vector and a 3-by-1 column vector and raise the row vector to the power of the column vector.
a = [2 3];b =(1:3)';a。^b
ans =3×22 3 4 9 8 27
结果是一个3 by-2矩阵,其中矩阵中的每个(i,j)元素等于a(j)。^ b(i)
:
Find Roots of Number
计算根源-1
到1/3
力量.
A = -1; B = 1/3; C = A.^B
C =0.5000 + 0.8660i
For negative baseA
和非企业B
, the力量
功能返回复杂的结果。
Use thenthroot
function to obtain the real roots.
C =nthroot(A,3)
C =-1
Input Arguments
A
,B
—Operands
标量|向量|矩阵|多维阵列
Operands, specified as scalars, vectors, matrices, or multidimensional arrays.A
和B
must either be the same size or have sizes that are compatible (for example,A
is anM
-经过-N
矩阵和B
是标量或1
-经过-N
行矢量)。有关更多信息,请参阅兼容阵列大小用于基本操作.
具有整数数据类型的操作数不能复杂。
Data Types:single
|double
|int8
|INT16
|INT32
|int64
|uint8
|UINT16
|uint32
|uint64
|logical
|char
Complex Number Support:Yes
More About
IEEECompliance
For real inputs,力量
has a few behaviors that differ from those recommended in the IEEE®-754 Standard.
MATLAB® | IEEE | |
---|---|---|
|
|
|
|
|
|
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, seeTall Arrays.
C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。
Usage notes and limitations:
当两个
X
和Y
are real, but力量(X,Y)
is complex, simulation produces an error and generated code returnsNaN
. To get the complex result, make the input valueX
complex by passing in复合物(x)
. For example,电力(复杂(x),y)
.当两个
X
和Y
are real, butX .^ Y
is complex, simulation produces an error and generated code returnsNaN
. To get the complex result, make the input valueX
complex by using复合物(x)
. For example,复杂(x)。^y
.代码生成不支持此功能的稀疏矩阵输入。万博1manbetx
GPU Code Generation
使用GPU CODER™为NVIDIA®GPU生成CUDA®代码。
Usage notes and limitations:
当两个
X
和Y
are real, but力量(X,Y)
is complex, simulation produces an error and generated code returnsNaN
. To get the complex result, make the input valueX
complex by passing in复合物(x)
. For example,电力(复杂(x),y)
.当两个
X
和Y
are real, butX .^ Y
is complex, simulation produces an error and generated code returnsNaN
. To get the complex result, make the input valueX
complex by using复合物(x)
. For example,复杂(x)。^y
.代码生成不支持此功能的稀疏矩阵输入。万博1manbetx
HDL Code Generation
使用HDL Coder™生成用于FPGA和ASIC设计的Verilog和VHDL代码。
Both inputs must be scalar, and the exponent input,k
,必须是一个整数。
Thread-Based Environment
Run code in the background using MATLAB®背景池
或者accelerate code with Parallel Computing Toolbox™螺纹池
.
This function fully supports thread-based environments. For more information, seeRun MATLAB Functions in Thread-Based Environment.
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
Usage notes and limitations:
不支持64位整数。万博1manbetx
有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
此功能完全支持分布式数组。万博1manbetx有关更多信息,请参阅运行具有分布式数组的MATLAB功能(Parallel Computing Toolbox).
Version History
在R2006a之前引入R2016b: Implicit expansion change affects arguments for operators
Behavior changed in R2016b
Starting in R2016b with the addition of implicit expansion, some combinations of arguments for basic operations that previously returned errors now produce results. For example, you previously could not add a row and a column vector, but those operands are now valid for addition. In other words, an expression like[1 2] + [1; 2]
previously returned a size mismatch error, but now it executes.
If your code uses element-wise operators and relies on the errors that MATLAB previously returned for mismatched sizes, particularly within a尝试
/catch
block, then your code might no longer catch those errors.
有关基本数组操作所需的输入尺寸的更多信息,请参见兼容阵列大小用于基本操作.
开放示例
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择一个网站
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:.
您还可以从以下列表中选择一个网站:
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.
美洲
- AméricaLatina(Español)
- Canada(English)
- 美国(English)
欧洲
- Belgium(English)
- 丹麦(English)
- Deutschland(德意志)
- españa(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- 意大利(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(德意志)
- Portugal(English)
- Sweden(English)
- 瑞士
- 英国(English)