我有一个在Matlab中维度为mxn
的二进制矩阵A
,其中m>n
。我想构建一个维度为cxn
的矩阵B
,按行列出包含在A
中的1的行索引的笛卡尔积的每个元素。为了更清楚地说明,请考虑以下示例。
示例:
%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