issue with a*a
6 次查看(过去 30 天)
显示 更早的评论
a=[2 4 6 8 10 ; 3 6 9 12 15;4 8 12 16 20]
a =
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
>> a*a Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
why i cannot find a*a in this case?
3 个评论
madhan ravi
2018-9-4
Accept the answers it’s a token of appreciation to people who take efforts to answer your question!
Stephen23
2018-9-4
@melissa tan: so far you have asked six questions, all of which have received good answers, but you have only accepted one of the answers, for your very first question.
Accepting answers is an easy way to show your appreciation to the volunteers who help you, and it indicates that your question has been resolved.
回答(1 个)
Stephen23
2018-9-4
编辑:Stephen23
2018-9-4
It depends on what you expect to happen:
1. If you expect to multiply each element with itself, then just follow the instructions in the error message. I copied them from your question: "To perform elementwise multiplication, use '.*' ".
Did you try doing that? It works for me:
>> a.*a
ans =
4 16 36 64 100
9 36 81 144 225
16 64 144 256 400
2. If you expect to multiply that matrix with itself (i.e. matrix multiplication), then that is impossible: the number of columns of the (first) matrix is not the same as the number of rows of the (second) matrix, so there is no way that works. (The fact that it is the same matrix is irrelevant).
As you have been told several times in the last few days, you need to learn the differences between matrix and array operations:
You HAVE to learn this!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!