Matlab-将矩阵提升为幂的不正确尺寸 [英] Matlab - Incorrect dimensions for raising a matrix to a power
问题描述
假设我们有 a = 60
和 B = 60
.我正在尝试计算该面积:
Suppose we have a=60
and B=60
. I am trying to calculate this area:
当我尝试此操作时:
W = ((u^2)* cot(B) + (v^2 * cot(a))/8;
我收到此错误:
将矩阵提升为幂的尺寸不正确.检查矩阵是否为正方形,幂是否为标量.要执行逐元素矩阵幂,使用.^".
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.
如何正确使用 u ^ 2
?
推荐答案
如果 u
和 v
是向量,则应编写 u.^ 2
和 v.^ 2
代替(逐个元素的运算符).当您编写 u ^ 2
时表示 u * u
,这并不意味着 u
不是平方矩阵时.
If u
and v
are a vector, you should write u.^2
and v.^2
instead (an element-wise operator). When you write u^2
means u * u
and it does not mean when u
is not a squared matrix.
但是,如果它们是向量,则并不意味着要计算 W
的值.
However, if they are vector, it is not meant for computing the value of W
.
这篇关于Matlab-将矩阵提升为幂的不正确尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!