Matrix Multiplication with its transpose in the loop
이전 댓글 표시
Hi,
Let's say I have a matrix
A = [1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8]
I need to do matrix multiplication i.e. A'*A, but not all the rows and the column at once. For example, I want to multiply the first two column of the matrix first and obtain a result (let's say r1), then column 1, 2 and 3 multiplied with its transpose, obtain the result (let's say r2) and then column 1,2,3, and 4 multiplied with its transpose and the result is r3 and so on. I have to save the result in the matrix, let's say B
B = [r1 0 0 0
r1 r2 0 0
r1 r2 r3 0
.....]
Can anyone help me with this?
Thank you!
댓글 수: 4
John Chilleri
2017년 1월 22일
편집: John Chilleri
2017년 1월 22일
A simple solution might just be to program matrix multiplication with some for loops and selectively store values.
David Goodmanson
2017년 1월 22일
Hi MD, Is there some kind of extra summation that you are not mentioning? If you take, say, a 10x10 matrix and multiply three columns worth of that by its transpose, then depending on which order you do the multiplication the result is either 10x10 or 3x3. In neither case is the result a scalar, as appears to be the case with matrix B.
Mystery Devil
2017년 1월 22일
Mystery Devil
2017년 1월 22일
답변 (1개)
Walter Roberson
2017년 1월 22일
for k=1:size(A,2)
T=A(:, 1:k);
B{k} = T'*T;
end
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!