Matrix calculation + loop

2 visualizaciones (últimos 30 días)
Florent Rouxelin
Florent Rouxelin el 29 de Jun. de 2017
Editada: Walter Roberson el 29 de Jun. de 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!

Respuestas (1)

James Tursa
James Tursa el 29 de Jun. de 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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by