All the posible combination of two matrices
1 次查看(过去 30 天)
显示 更早的评论
I have two matrix
A=[1]
and
B=[2 3 4]
find the all possible combination of these tow matrices is
the output
C=[1 2; 1 3; 1 4; 1 2 3; 1 2 4; 1 3 4; 1 2 3 4]
how to find it
0 个评论
采纳的回答
Andrei Bobrov
2012-12-17
编辑:Andrei Bobrov
2012-12-17
C = [];
for j1 = 1:numel(B)
a = nchoosek(B,j1);
C = [C;num2cell([repmat(A,size(a,1),1),a],2)];
end
更多回答(1 个)
Walter Roberson
2012-12-17
You cannot create a numeric matrix with a variable number of elements in each row.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!