What does operator “dot” (.) mean?
Question:
Given the code :
A = [1 2 3; 3 2 1]
B = A.^2
The output :
B =
1 4 9
9 4 1
But if I do this : B = A^2
The output is :
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.
The .^
is a pointwise¹ (i.e. element-wise) power, as .*
is the
pointwise product.
.^
Array power.A.^B
is the matrix with elementsA(i,j)
to theB(i,j)
power.A
andB
must have the same size, unless one of them is a scalar.
C.f.
- "Matrix and array arithmetic": http://www.mathworks.de/help/techdoc/ref/arithmeticoperators.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
¹) Hence the dot.
想要看到更多学习笔记、考试复习资料、面试准备资料?
想要看到IBM工作时期的技术积累和国外初创公司的经验总结?
敬请关注:
[CSDN](https://blog.csdn.net/u013152895)
[简书](https://www.jianshu.com/u/594a3de3852d)
[博客园](https://www.cnblogs.com/vigorz/)
[51Testing](http://www.51testing.com/?15263728)