필터 지우기
필터 지우기

Appending column vectors produced from a for loop

조회 수: 2 (최근 30일)
Arthur Batte
Arthur Batte 2020년 7월 18일
답변: julian navas 2020년 7월 19일
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

채택된 답변

julian navas
julian navas 2020년 7월 19일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by