help to multiply matrices in succession

조회 수: 6 (최근 30일)
Marco
Marco 2012년 11월 21일
Hi,
I initialized this objects:
C = vpa(zeros(4, 4, N));
A = vpa(zeros(4,4,N));
where C is:
for i = 1:N
C(:,:,i) = [(cos(theta(i))) (-sin(theta(i))).*(cos(alpha(i))) (sin(theta(i))).*(sin(alpha(i))) (a(i)).*(cos(theta(i)));
(sin(theta(i))) (cos(theta(i))).*(cos(alpha(i))) (-cos(theta(i))).*(sin(alpha(i))) (a(i)).*(sin(theta(i)));
0 sin(alpha(i)) cos(alpha(i)) d(i);
0 0 0 1];
end
Well, I need that
A(:,:,1)=C(:,:,1);
but elements:
A(:,:,2) ....... A(:,:,N) must be obtained as
A(:,:,2) = C(:,:,1) * C(:,:,2)
A(:,:,3) = C(:,:,1) * C(:,:,2) * C(:,:,3)
etc
....
A(:,:,N) = C(:,:,1) * C(:,:,2) * C(:,:,3) * ....* C(:,:,N)
some tips ?

채택된 답변

Matt Fig
Matt Fig 2012년 11월 21일
편집: Matt Fig 2012년 11월 21일
% For example:
C = randi(10,2,2,3)
A = cumprod(C,3)
Or perhaps you meant:
A(:,:,1) = C(:,:,1);
for ii = 2:size(C,3)
A(:,:,ii) = A(:,:,ii-1)*C(:,:,ii);
end
  댓글 수: 3
Matt Fig
Matt Fig 2012년 11월 21일
Hello Marco, did you see the second option?
Marco
Marco 2012년 11월 21일
Yes, thanks!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by