How can I add a column of data to a matrix

1 view (last 30 days)
Tyler S
Tyler S on 1 Apr 2020
Commented: David Hill on 1 Apr 2020
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 Comment
Tyler S
Tyler S on 1 Apr 2020
So the result of this would make A1=[1,2,3,10;4,5,6,11;7,8,9,12]

Sign in to comment.

Answers (2)

David Hill
David Hill on 1 Apr 2020
A1=[A1;b1];
  2 Comments
Tyler S
Tyler S on 1 Apr 2020
Thats adding a row if im not mistaken I need to add b to the end of A so it adds a new column

Sign in to comment.


darova
darova on 1 Apr 2020
Try my solution
A = [A b(:)]

Categories

Find more on Matrices and Arrays 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!