How to write a 'horizontal direct product' (*~) from Gauss in Matlab?

5 ビュー (過去 30 日間)
Patrick
Patrick 2012 年 8 月 18 日
Hi,
I am trying to write the 'horizontal direct product' (*~) from Gauss in Matlab. Anyone can help me?
E.g. Horizontal direct product z = x*~y;
x = [1 2; 3 4]; y = [5 6; 7 8];
z = [5 6 10 12; 21 24 28 32]
NB. The input matrices x and y must have the same number of rows. The result will have cols( x) * cols( y) columns.
Thanks!

採用された回答

Matt Fig
Matt Fig 2012 年 8 月 18 日
z = repmat(y,1,size(x,2)).*kron(x,ones(1,size(y,2)))

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 8 月 18 日
That is a subset of the output of kron(x,y)
  2 件のコメント
Patrick
Patrick 2012 年 8 月 18 日
Thanks, Walter. I noted that, but do you know how to extract this subset?
Walter Roberson
Walter Roberson 2012 年 8 月 18 日
Row indexing, but I do not know what the general pattern is (I would need a few additional examples of different lengths to go on.)

サインインしてコメントする。


Patrick
Patrick 2012 年 8 月 20 日
Thanks, Matt. That's perfect.

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by