Borrar filtros
Borrar filtros

Appending column vectors produced from a for loop

2 visualizaciones (últimos 30 días)
Arthur Batte
Arthur Batte el 18 de Jul. de 2020
Respondida: julian navas el 19 de Jul. de 2020
Hello, i wish to append end to end column vectors produced in a for loop. Eg if two column vectors given below are produced from a for loop.
1 8
2 6
3 1
4 9
these two column vectors then append/merge one at the end of the other to
1
2
3
4
8
6
1
9
Could anyone kindly assist on how to go around this. Kindly provide me a solution whereby the for loop was producing say 20 column vectors thereby appending all these 20 column vectors
thank you

Respuesta aceptada

julian navas
julian navas el 19 de Jul. de 2020
There are several ways to accomplish what you're saying, unfortunately the question does not provide enough information to delimit the scope of the answers you could get and thus the one you really need.
%option1
for i = 1:3
vec1 = rand(4,1)
vec2 = rand(4,1)
end
var = [vec1;vec2]
%option 2
var = [];
for i = 1:3
var = [var;rand(4,1)]
end
...and so on, depending on the data structure you have.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by