I don't know if it's better -- what is here is pretty straightforward -- but you could define the final dimensioned matrix of zero and put the pieces in

```
big = max(A.cols, B.cols)
M = zeros(rows, 2*big
M[0,0]=A
M[0, big]=B
```