Matlab - Incorrect dimensions for raising a matrix to a power [closed]

点点圈 提交于 2021-02-05 12:32:06

问题


Suppose we have a=60 and B=60. I am trying to calculate this area:

when I try this:

W = ((u^2)* cot(B) + (v^2 * cot(a))/8;

I get this error:

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

How can I use u^2 in the right way?


回答1:


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.

However, if they are vector, it is not meant for computing the value of W.



来源:https://stackoverflow.com/questions/59022821/matlab-incorrect-dimensions-for-raising-a-matrix-to-a-power

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!