gpt4 book ai didi

matlab - 运算符 "dot"(.) 是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-03 19:06:12 25 4
gpt4 key购买 nike

给定代码:

 A = [1 2 3; 3 2 1]
B = A.^2

输出:

B =

1 4 9
9 4 1

但如果我这样做:B = A^2

输出是:

Error using  ^ 
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

运算符 . 究竟做了什么?

最佳答案

点本身不是运算符,.^ 是。

.^ 是逐点 ¹(即逐元素)幂,因为 .*pointwise product .

.^ Array power. A.^B is the matrix with elements A(i,j) to the B(i,j) power. The sizes of A and B must be the same or be compatible.

比照

¹) 因此点。

关于matlab - 运算符 "dot"(.) 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10859917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com