运算符“点"是什么意思(.) 意思是? [英] What does operator "dot" (.) mean?

查看:643
本文介绍了运算符“点"是什么意思(.) 意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出代码:

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

输出:

B =

     1     4     9
     9     4     1

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

But if I do this : 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.

.^是逐点¹(即逐元素)的幂,因为.*按点积.

The .^ is a pointwise¹ (i.e. element-wise) power, as .* is the pointwise product.

.^ 阵列电源. A.^B是具有B(i,j)次幂的元素A(i,j)的矩阵. AB的大小必须相同或兼容.

.^ 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.

C.f.

  • "Array vs. Matrix Operations": 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

¹)因此是点.

这篇关于运算符“点"是什么意思(.) 意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆