Loop for 1:100
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marko Niko
el 14 de Feb. de 2023
Comentada: Torsten
el 15 de Feb. de 2023
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
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?
0 comentarios
Respuesta aceptada
Torsten
el 14 de Feb. de 2023
Editada: Torsten
el 14 de Feb. de 2023
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 comentarios
Torsten
el 15 de Feb. de 2023
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)
Más respuestas (0)
Ver también
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!