issue with a*a
조회 수: 5 (최근 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!