필터 지우기
필터 지우기

concatenate vectors

조회 수: 5 (최근 30일)
Miriam
Miriam 2011년 11월 10일
Hi, let's say I have e.g. three column-vectors a(nx1), b(nx1), c(nx1) I want to concatinate them to have another column-vector (nx1) which has a,b,c inside one after another. How do I do this? Any help regarding that question is appreciated! Thanks in advance!

답변 (3개)

Titus Edelhofer
Titus Edelhofer 2011년 11월 10일
Hi Miriam,
now with column vectors. Does this what you expect?
a = [1; 2];
b = [3; 4; 5];
c = [6; 7];
d = [a; b; c]
Titus
  댓글 수: 3
Miriam
Miriam 2011년 11월 10일
I changed it in the question, thanks for the remark.
Titus Edelhofer
Titus Edelhofer 2011년 11월 10일
updated as well ;-)

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2011년 11월 10일
You cannot do that with numeric vectors. Numeric vectors do not permit nesting.
An nx1 vector is a column vector, by the way, not a row vector.
The code below creates an n x 1 cell array in which each entry is [a(k),b(k),c(k)]
NewArray = mat2cell([a,b,c], ones(1,length(a)), 3 );
I would, though, tend to think that likely whatever you are doing would be more easily done by creating an n x 3 array:
NewArray = [a,b,c];

William
William 2011년 11월 10일
Newvect = [a(nx1);b(nx1);c(nx1)]
or
Newvect = [a(nx1) b(nx1)c(nx1)]
or try
help strcat
help horzcat
  댓글 수: 1
Miriam
Miriam 2011년 11월 10일
ok great, that's it, thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by