MATLAB: How to create a series of permutation matrices

#nchoosekncrpermutations

Hi all,
I'm new, and my maths isn't great. Was wondering if anyone could help me..
I want to create a series of matrices (zeros(3,3)) that show all possible combinations of making 1-6 of the 9 values a 1.
Mathematically, this should produce; 9nCr1 = 9 + 9nCr2 = 36 + 9nCr3 = 84 + 9nCr4 = 126 + 9nCr5 = 126 + 9nCr6 = 84 = 465 separate matrices
Does anyone know how to do that without manually specifying all of them?

Best Answer

a = dec2bin(0:511,9) - '0';
n = sum(a,2);
out = reshape(a(n <= 6 & n >= 1,:).',3,3,[]);
ADD
a = dec2bin(0:511,9) - '0';
n = sum(a,2);
out = reshape(a(n <= 6 & n >= 1 & all(a(:,[1:4:9])==0,2),:).',3,3,[]);