how can make a matrix from many vectors?

16 views (last 30 days)
fatemeh
fatemeh on 18 Oct 2013
Commented: Azzi Abdelmalek on 18 Oct 2013
how can make a matrix from many vectors?
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 18 Oct 2013
You should precise column vectors or row vectors?
fatemeh
fatemeh on 18 Oct 2013
yes row vectors with same size 1*2,actually i have a for loop and it each time produce a vector with size 1*2 ,i want save this vector each time to a matrix

Sign in to comment.

Answers (3)

vaishali
vaishali on 18 Oct 2013
C = horzcat(A1, A2, ...) horizontally concatenates matrices A1, A2, and so on. All matrices in the argument list must have the same number of rows

Jos (10584)
Jos (10584) on 18 Oct 2013
Edited: Jos (10584) on 18 Oct 2013
... and if the vectors are not of the same lengths, you can use PADCAT

Azzi Abdelmalek
Azzi Abdelmalek on 18 Oct 2013
out=[A1;A2;A3;...]
  1 Comment
Azzi Abdelmalek
Azzi Abdelmalek on 18 Oct 2013
Edited: Azzi Abdelmalek on 18 Oct 2013
out=zeros(1000,2) % Pre-allocate
for k=1:1000
out(k,:)=... % your calculations
end

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!