Adding every loop a matrix from the right side to a matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Lars Urban
el 10 de Mayo de 2022
Comentada: KSSV
el 10 de Mayo de 2022
I want to add after one loop a matrix to a matrix that was calculated one loop before. For example in the first loop the matrix would be 2x2 after second loop 2x4 and the next one 2x6 ...
I know that "manually" it would be i think like this
A = [1,2;3,4]
B(:,1:2) = A
B(:,3:4) = A
But how would this look like in a loop?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Davide Masiello
el 10 de Mayo de 2022
Editada: Davide Masiello
el 10 de Mayo de 2022
In the example below, a new 2x2 random matrix is created at each new iteration and appended to an existing matrix A.
clear,clc
A = [];
for i = 1:10
B = rand(2,2);
A = [A,B];
end
A
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!