主要内容

力量,。^

元素能力

描述

example

C =A。^B提出的每个元素A到corresponding powers inB. The sizes ofABmust be the same or becompatible.

If the sizes ofABare compatible, then the two arrays implicitly expand to match each other. For example, if one ofA或者B是标量,然后将标量与另一个数组的每个元素组合。同样,具有不同方向的向量(一个行矢量和一个列向量)隐式扩展以形成矩阵。

C =力量(A,B)is an alternate way to executeA.^B, but is rarely used. It enables operator overloading for classes.

Examples

collapse all

创建一个向量,A, and square each element.

a = 1:5;C = A.^2
C =1×51 4 9 16 25

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):

a = [ a 1 a 2 ] , b = [ b 1 b 2 b 3 ] , a . ˆ b = [ a 1 b 1 a 2 b 1 a 1 b 2 a 2 b 2 a 1 b 3 a 2 b 3 ] .

计算根源-11/3力量.

A = -1; B = 1/3; C = A.^B
C =0.5000 + 0.8660i

For negative baseA和非企业B, the力量功能返回复杂的结果。

Use thenthrootfunction to obtain the real roots.

C =nthroot(A,3)
C =-1

Input Arguments

collapse all

Operands, specified as scalars, vectors, matrices, or multidimensional arrays.ABmust either be the same size or have sizes that are compatible (for example,Ais 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

collapse all

IEEECompliance

For real inputs,力量has a few behaviors that differ from those recommended in the IEEE®-754 Standard.

MATLAB® IEEE

力量(1,NaN)

NaN

1

力量(NaN,0)

NaN

1

Extended Capabilities

Version History

在R2006a之前引入

expand all

Behavior changed in R2016b