Need help in coding this summation, please.

조회 수: 1 (최근 30일)
Luciano Campos
Luciano Campos 2016년 3월 11일
댓글: Ced 2016년 3월 12일
Hi,
Can anybody help me with coding this summation into matlab, please:
where J is (3x6), A is (6x6) and Phi is (3x3x9).
I've tried with this code:
% for ii=1:hor
for mm=1:ii
G(:,:,ii)=sum(kron(J*A'^(ii-mm),Phi(:,:,mm)),3);
end
end %
but it doesn't seem to work, as I get incorrect results. I think the mistake is in the sum function, but I don't know other way of coding the summation (cumsum function doesn't work either).
I'd really appreciate some help here, as I'm completely stuck.
best,
  댓글 수: 3
Luciano Campos
Luciano Campos 2016년 3월 11일
Hi Ced, Thanks for your comment. I tried what you suggest, but it still won't work. The original formula is correct. If you develop the original summation you get:
I think the problem is that I don't know how to sum up consecutive terms as neither sum nor cumsum function seem to work.
Thanks for your help,
best,
Ced
Ced 2016년 3월 11일
편집: Ced 2016년 3월 11일
I just found it strange to start G indexing a 1, but Phi indexing at 0.
Yeah, I messed up, sorry. Your original equation looks correct to me, but yes, you sum up too much. With sum, for each mm, you sum up over all of Phi again, which is not what you want.
Assuming you initialize G with zero:
for ii=1:hor
for mm=1:ii
G(:,:,ii) = G(:,:,ii) + kron(J*A'^(ii-mm),Phi(:,:,mm));
end
end

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

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 12일
Is the x in a circle indicating cross-product or is it indicating exclusive or?
  댓글 수: 1
Ced
Ced 2016년 3월 12일
I believe it stands for the tensor product, hence the kronecker operator.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by