Matlab gives error on empty line

Hi! I was writing a code for an exercise but i was keep getting the same error on the same line as
"Error using ^ (line 51)
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 '.^'."
i dont even have "^" symbol on that line and i delete the whole line even though it gives the same error and when i click "line 51" it opens a new window called mpower and shows 51th line which again with no "^" symbol.
Can you help me with this?

1 个评论

Most symbols in Matlab will call a function internally: + will call plus, - will call minus, etc. So when you see ^, that will call mpower. Because most people will use ^ instead of directly calling mpower, the error message contains the symbol instead.
Walter already answered your question. If it solved your issue, you should accept his answer. If not, feel free to post follow-up questions in a comment to either this question, or his answer.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2021-5-13

1 个投票

The important part is Untitled line 43, which is the assignment to K_fc .
On that line you have three places where you have expressions ^2 . At least one of the expressions is resulting in something that is not a square matrix. For example eta might be a row vector. When you want to square a vector you need to use .^ instead of ^
If you are working with vectors, then chances are high that you need to be using ./ instead of / . You might well also be needing to use .* instead of * on the line.

7 个评论

Hi, Walter, sorry to ask an irrelevant question here. Since yesterday(or earlier), I can not post a question in Matlab Answers. At first, I thought the webpage is down. But later I found out that others can post questions. I contacted mathworks support, but they did not give any feedback. Maybe because I am using a student license, which only contains activation help and bug report.
Is my account suspened? Have you ever encountered this? Or do you know where I can get help about this?
Mathworks would have notified you if it had suspended your account for policy violations. The only time it does not notify people is for spammers. If your account had been suspended, you would not have been able to post your comment.
I have not heard of any system problems recently.
I would suggest that you clear your browser cache; if that is not enough, try using a different browser, as there are sometimes problems that only affect one manufacturer of browsers.
@Xingwang Yong: A bug in our system prevented some users from posting since yesterday evening. A fix was released today and you should expect things to be working now.
@Tushal Desai I still can not post questions. I will wait to see if it works later.
Can you try again after clearing your cookies and cache? Do you see any errors when asking question?
It works now.
Earlier, I cleared the cookies and cache, and it does not help. I wait several hours and tried again, it worked.
Thank you for confirming and sorry for the inconvenience.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

提问:

BBB
2021-5-13

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by