MATLAB: copy a row or column of a matrix and insert it in the next row/column?

You can simply repeat the indices of the rows you'd like to repeat.

Up vote 4 down vote favorite share g+ share fb share tw.

I was wondering if there is an easy way in MATLAB to do the following operation: I'd like to copy a row or column of a matrix and insert it in the next row/column. For example: given a 3x3 matrix 1 2 3 4 5 6 7 8 9 I'd like to copy the first row and insert it as a second row: 1 2 3 1 2 3 4 5 6 7 8 9 Can someone advise how I could accomplish this in MATLAB? Thanks!

Matlab link|improve this question edited Jun 5 '11 at 23:09John Zwinck14.8k1739 asked Jun 5 '11 at 23:04freddy304 50% accept rate.

You can simply repeat the indices of the rows you'd like to repeat A = A(1 1 2 3,:).

To insert row number source as row number target: A = A(1:target-1,:); A(source,:); A(target:end,:).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions