运算符“dot"是什么意思(.) 意思? [英] What does operator "dot" (.) mean?
本文介绍了运算符“dot"是什么意思(.) 意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定代码:
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.
运算符 .
究竟做了什么?
What does the operator .
do exactly ?
推荐答案
点本身不是运算符,.^
是.
The dot itself is not an operator, .^
is.
.^
是 pointwise¹(即元素方面)幂,因为 .*
是 逐点产品.
The .^
is a pointwise¹ (i.e. element-wise) power, as .*
is the pointwise product.
.^
阵列功率.A.^B
是元素 A(i,j)
到 B(i,j)
次幂的矩阵.A
和 B
的大小必须相同或兼容.
.^
Array power.A.^B
is the matrix with elementsA(i,j)
to theB(i,j)
power. The sizes ofA
andB
must be the same or be compatible.
C.f.
- 数组与矩阵运算":https://mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html
- "Pointwise":http://en.wikipedia.org/wiki/Pointwise
- Element-Wise Operations":http://www.glue.umd.edu/afs/glue.umd.edu/system/info/olh/Numerical/Matlab_Matrix_Manipulation_Software/Matrix_Vector_Operations/elementwise
¹) 因此点.
这篇关于运算符“dot"是什么意思(.) 意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文