Effacer les filtres
Effacer les filtres

Appending column vectors produced from a for loop

2 vues (au cours des 30 derniers jours)
Arthur Batte
Arthur Batte le 18 Juil 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

Réponse acceptée

julian navas
julian navas le 19 Juil 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.

Plus de réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by