필터 지우기
필터 지우기

Loop for 1:100

조회 수: 20 (최근 30일)
Marko Niko
Marko Niko 2023년 2월 14일
댓글: Torsten 2023년 2월 15일
for i=1:101
A_cont(i,i:i+100)=AH(1:101);
A_low_cont(i,i:i+100)=A_low(1:101);
A_high_cont(i,i:i+100)=A_high(1:101);
B_cont(i,i:i+100)=B1(1:101);
C_cont(i,i:i+100)=C1(1:101);
end
Unrecognized function or variable 'AH'.
I have this code but I'm not sure what does (i,i:i+100) would mean in this loop. Does it calculate i for every step through i+100? How would the matrix look like?

채택된 답변

Torsten
Torsten 2023년 2월 14일
편집: Torsten 2023년 2월 14일
A_cont is a matrix of size 101 x 201.
In row i of A_cont, the array AH(1:101) is stored in columns i to i+100 (thus in the part in and above the diagonal) for all i ranging from 1 to 101.
The lower diagonal part of A_cont consists of zeros.
Same for the other matrices involved.
  댓글 수: 2
Marko Niko
Marko Niko 2023년 2월 14일
Hi Torsten,
Could you elaborate on the "lower diagonal" part of A_cont? Would be great if you can visualize it.
Thank you so much.
Torsten
Torsten 2023년 2월 15일
AH = rand(1,101);
A_cont = zeros(101,201);
for i = 1:101
A_cont(i,i:i+100)=AH(1:101);
end
spy(A_cont)

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

추가 답변 (0개)

카테고리

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