test
Posts:
19
Registered:
12/11/04


Re: "Expanding matrices"
Posted:
Apr 8, 2013 1:31 PM


Have you tried bsxfun?
"Jono" wrote in message <kjusll$kgc$1@newscl01ah.mathworks.com>... > 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

