How to append elements in a vector one by one
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm given two vector and i'm supposed to append the elements of the second matrix to the first matrix one by one, i can do this together but i cant seem to do it one by one, am i supposed to use a for loop somewhere?
%define vector A
A = [1 2 4] ;
%define vector B
B = [5 6 7] ;
%append B to A
A = [A,B]
댓글 수: 0
답변 (1개)
madhan ravi
2019년 3월 21일
No loop is needed: Vertically concatenate the two vectors and use reshape.
댓글 수: 1
madhan ravi
2019년 3월 21일
Try the suggested answer if it doesn’t do what you want , upload what you have tried.
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!