how can i add row to matrix

like a =
0 2 3
1 1 1
7 8 9
and make it like this
a =
0 2 3
7 8 9
1 1 1
7 8 9

 Accepted Answer

mohammed - you could try
a = [a(1,:) ; a(3,:) ; a(2:3,:)]
We use the square brackets [] to concatenate the set of row together to make the new a.

More Answers (2)

>> a([1,3,2,3],:)
ans =
0 2 3
7 8 9
1 1 1
7 8 9
Anoop Singh
Anoop Singh on 24 Feb 2019
Edited: Anoop Singh on 24 Feb 2019
a = cat(1, a(1,:), a(3,:), a(2:3,:))

Categories

Tags

Community Treasure Hunt

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

Start Hunting!