When I used the following command on MATLAB I got the error
>> D1d = D_pca(:,1)*eigvects(:,1)
Error using *
Inner matrix dimensions must agree.
But when I added the ' at the end then the error disappeared.
>> D1d = D_pca(:,1)*eigvects(:,1)'
D1d =
6.1500 -2.0524
-1.9502 0.6508
-8.6987 2.9029
4.4990 -1.5014
I need to help with why this happened? What is the reason behind it? What does the comma do?

 채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 27일
편집: Walter Roberson 2021년 9월 27일

1 개 추천

Your D_pca has 4 rows and an unknown number of columns.
Your eigvects has 2 rows and an unknown number of columns.
D_pca(:,1)*eigvects(:,1)
is a request to use algebraic matrix multiplication (inner product) between a 4 x 1 vector and a 2 x 1 vector. But for inner product, the number of columns in the first operand (which is 1 in this case) must match the number of rows in the second operand (which is 2 in this case).
When you ask D_pca(:,1)*eigvects(:,1)' then you are asking to have inner product between a 4 x 1 matrix and transpose of a 2 x 1 vector, which is 4 x 1 * 1 x 2, and then the "inner dimensions" match so you can multiply and produce a 4 x 2 result.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2016b

태그

Community Treasure Hunt

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

Start Hunting!

Translated by