Hi threre.
I have the following matrices and the code I am running to get the sum of matrices:
A = sparse matrix (20000x20000)
I = matrix identity of A
for ii = 1:200
C{ii} = A^ii;
L = I + C{ii};
end
What I would like to get as result is L = I+C{1}+C{2}+C{3}...+C{200}.
However I am getting L = I+C{200}.
Could you help me to find the mistake, please?

 채택된 답변

Matt J
Matt J 2022년 3월 26일
편집: Matt J 2022년 3월 26일

1 개 추천

A = sparse matrix (20000x20000)
L = speye(size(A));
for ii = 1:200
C{ii} = A^ii;
L = L + C{ii};
end

댓글 수: 3

I see.
should set a L matrix before run the code.
Thanks a lot dear Matt.
Cheers
The main change was
L = L + C{ii};
Yes, I got you.
Many thanks.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2022년 3월 26일

댓글:

2022년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by