Need help in coding this summation, please.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Luciano Campos
am 11 Mär. 2016
Kommentiert: Ced
am 12 Mär. 2016
Hi,
Can anybody help me with coding this summation into matlab, please:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/157553/image.png)
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 Kommentare
Ced
am 11 Mär. 2016
Bearbeitet: Ced
am 11 Mär. 2016
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
Akzeptierte Antwort
Walter Roberson
am 12 Mär. 2016
Is the x in a circle indicating cross-product or is it indicating exclusive or?
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!