我有一个二维矩阵A
的尺寸mxn
与m>n
在Matlab中。我想构建一个尺寸为cxn
的矩阵B
,列出A
中包含行索引的笛卡尔乘积的每个元素。要更清楚地考虑下面的例子。在Matlab中的行索引的笛卡尔乘积
例子:
%m=4;
%n=3;
A=[1 0 1;
0 0 1;
1 1 0;
0 0 1];
%column 1: "1" are at rows {1,3}
%column 2: "1" are at row {3}
%column 3: "1" are at rows {1,2,4}
%Hence, the Cartesian product {1,3}x{3}x{1,2,4} is
%{(1,3,1),(1,3,2),(1,3,4),(3,3,1),(3,3,2),(3,3,4)}
%I construct B by disposing row-wise each 3-tuple in the Cartesian product
%c=6
B=[1 3 1;
1 3 2;
1 3 4;
3 3 1;
3 3 2;
3 3 4];
警告。 'combvec'属于神经网络工具箱。 – rayryeng