```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: "Expanding matrices"
Date: Mon, 8 Apr 2013 16:53:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <kjusll\$kgc\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1365439989 21004 172.30.248.47 (8 Apr 2013 16:53:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 8 Apr 2013 16:53:09 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:792960

There may be some very simple function for this I'm unaware of but I'm trying to multiply out matrices as if they were brackets whilst retaining all the terms.

For example

Phase1=[A ;
B]
Phase2=[C , D ;
E, F]
Phase3=[ G;
H;
I]

I'm trying to multiply each of these out so the end result would be
Phases=[A , C, D, G;
A , C, D, H;
A , C, D, I;
A , E, F, G;
A , E, F, H;
A , E, F, I;
B , C, D, G;
B , C, D, H;
B , C, D, I;
B , E, F, G;
B , E, F, H;
B , E, F, I;]

However, there will be an unknown number of 'phases' (matrices) and these will be an unknown number of rows and columns.

Firstly I'm asking is there a simple function to combine two matrices together row by row as I'm sure I can work from there. If not does anyone have any recommendations about how to go about this as my initial thought was it needs an unknown number of 'for' loops. Also some matrices may be getting on for 10^6 in length so any hints on speeding up the code would be appreciated.

If I haven't explained this clearly please let me know!

Thanks,

Jon
```