# Interleave rows of two n by m matrices, using matlab

## Alec Jacobson

## February 16, 2010

I have to 3 by 2 matrices:
```
/1 2\
A = | 3 4 |
\5 6/
/9 8\
B = | 7 6 |
\5 4/
```

and I want to interleave leave their rows into a 6 by 2 matrix, C:
```
/1 2\
| 9 8 |
C = | 3 4 |
| 7 6 |
| 5 6 |
\5 4/
```

To achieve this in matlab I use the following:
```
reshape([A(:) B(:)]',size(A,1)+size(B,1), [])
```

Perhaps there is a better way?