How can I add a column of data to a matrix

조회 수: 1 (최근 30일)
Tyler S
Tyler S 2020년 4월 1일
댓글: David Hill 2020년 4월 1일
I have matrix A1=[1,2,3;4,5,6;7,8,9] and b1 = [10,11,12] and I want to add it to the end of matrix A1 so that A1's size will become 3x4 instead of 3x3
  댓글 수: 1
Tyler S
Tyler S 2020년 4월 1일
So the result of this would make A1=[1,2,3,10;4,5,6,11;7,8,9,12]

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

답변 (2개)

David Hill
David Hill 2020년 4월 1일
A1=[A1;b1];
  댓글 수: 2
Tyler S
Tyler S 2020년 4월 1일
Thats adding a row if im not mistaken I need to add b to the end of A so it adds a new column
David Hill
David Hill 2020년 4월 1일
A1=[A1,b1'];

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


darova
darova 2020년 4월 1일
Try my solution
A = [A b(:)]

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by