## Append rows at the end of Matrix

### Trushit (view profile)

on 27 Jan 2014
Latest activity Answered by Michael Hawks

on 2 May 2019

### Azzi Abdelmalek (view profile)

Hi,
a = [1 2 3 ; 4 5 6; 7 8 9]; --> 3x3 matrix
I want to insert at the end number of raws with same elements such as [5 5 5] and make the matrix 10 x 3 i.e. I want to insert 7 more raws with [5 5 5]. Please explain.

### Azzi Abdelmalek (view profile)

on 27 Jan 2014
Edited by Azzi Abdelmalek

### Azzi Abdelmalek (view profile)

on 27 Jan 2014

a = [1 2 3 ; 4 5 6; 7 8 9];
b=[5 5 5]

Trushit

### Trushit (view profile)

on 30 Jan 2014
Thanks a lot. The answer also helps when we have different elements in stead of all same.
shubham shinde

### shubham shinde (view profile)

on 11 Apr 2017
What if I have to insert the row somewhere between middle of the original matrix? Thank you in advance.
Hugh

### Hugh (view profile)

on 19 Sep 2018
Yes, a long-time-after answer to a long-time-after question, but why not?
a = [1 2 3; 4 5 6; 7 8 9];
b = [5 5 5];
a = [a(1,1:3);b;a(2:3,1:3)]
Or for a bit more malleable solution (variable row to add to):
a = [1 2 3; 4 5 6; 7 8 9];
b = [5 5 5];
Or a bit prettier, and even more malleable (if a has variable number of rows):
a = [1 2 3; 4 5 6; 7 8 9];
b = [5 5 5];

### Amit (view profile)

on 27 Jan 2014

A = [1 2 3;4 5 6;7 8 9];
A = [A; ones(7,3)*5];

Trushit

### Trushit (view profile)

on 30 Jan 2014
Thank you. It's short and speedy.

### Michael Hawks (view profile)

on 2 May 2019

Another method:
a = [1 2 3 ; 4 5 6; 7 8 9];
b=[5 5 5];
a( end+1, : ) = b;
or
a( :, end+1 ) = b';