How can I generate all possible combinations of a matrix which have a certain value?

1 次查看(过去 30 天)
How can matlab provide all possible combinations of a matrix which equals to zero? For example: I have the matrix a=[0 1 0; 1 1 0; 0 1 1] and matlab has to give the answer: 1 3 7 8, 1 3 7, 1 3 8, 1 7 8, 3 7 8, 1 3, 1 7, 1 8, 3 7, 3 8, 7 8.

采纳的回答

Andrei Bobrov
Andrei Bobrov 2014-10-20
n = find(a==0);
out = arrayfun(@(x)nchoosek(n,x),numel(n):-1:2,'un',0)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by