필터 지우기
필터 지우기

Add column vector to the end of another column vector

조회 수: 19 (최근 30일)
Wilson Meireles
Wilson Meireles 2023년 10월 31일
댓글: Voss 2023년 10월 31일
Hello! I have two rather large data sets that I am trying to combine into one data set. For example vector A is a 50x1 vector and vector B is a 100x1 vector. How do I combine these two togeher to get a 150x1 vector? Thanks so much!

채택된 답변

Hans Scharler
Hans Scharler 2023년 10월 31일
이동: Voss 2023년 10월 31일
A = rand(50,1); % example 50x1 vector
B = rand(100,1); % example 100x1 vector
C = vertcat(A,B) % concatenate A and B vertically
C = 150×1
0.6165 0.3890 0.8584 0.7299 0.1972 0.8609 0.3899 0.5217 0.3926 0.0891
  댓글 수: 4
Dyuman Joshi
Dyuman Joshi 2023년 10월 31일
@Wilson Meireles, The methods are equivalent, just the syntax is different.
From the documentation of vertcat - "vertcat is equivalent to using square brackets to vertically concatenate or append arrays. For example, [A; B] is the same as vertcat(A,B) when A and B are compatible arrays."
Voss
Voss 2023년 10월 31일
@Wilson Meireles: If the problem is solved, don't forget to "Accept" this answer.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by