Filter löschen
Filter löschen

Matrix calculation + loop

1 Ansicht (letzte 30 Tage)
Florent Rouxelin
Florent Rouxelin am 29 Jun. 2017
Bearbeitet: Walter Roberson am 29 Jun. 2017
Does anyone knows to program the following in Matlab?
B0 [4x4]
I [4x4]
sigma [4x4]
Here is what I have so far, but this is wrong:
I = ones(4);
sigma_sum=V;
for t = 1:(T-1)
block=I;
for i = 1:t
block = (block + B0.^i)*V*(block + B0.^i)';
end
sigma_sum = sigma_sum + block;
end
Thanks for your help!

Antworten (1)

James Tursa
James Tursa am 29 Jun. 2017
Maybe this is what you want:
B0 = whatever
V = whatever
sigma_sum = V;
M = eye(4); % <-- I am guessing that you really need eye(4) here instead of ones(4)
for t=1:(T-1)
M = M + B0^t; % <-- Used ^t instead of .^t here ... again I am guessing a bit here
sigma_sum = sigma_sum + M*V*M';
end

Kategorien

Mehr zu Loops and Conditional Statements 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!

Translated by