Filter löschen
Filter löschen

Appending column vectors produced from a for loop

2 Ansichten (letzte 30 Tage)
Arthur Batte
Arthur Batte am 18 Jul. 2020
Beantwortet: julian navas am 19 Jul. 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

Akzeptierte Antwort

julian navas
julian navas am 19 Jul. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by