필터 지우기
필터 지우기

Matrix calculation + loop

조회 수: 1 (최근 30일)
Florent Rouxelin
Florent Rouxelin 2017년 6월 29일
편집: Walter Roberson 2017년 6월 29일
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!

답변 (1개)

James Tursa
James Tursa 2017년 6월 29일
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

카테고리

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