问题
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