From: Roger Stafford on
"yang " <macmaster_egypt(a)yahoogroups.com> wrote in message <i1ifas$r3q$1(a)fred.mathworks.com>...
> Thanks for your quick reply,
>
> 1-let us called them
>
> > z1=( 0 0 1 1 1)
> > z2=(0 1 0 1 1)
> > z3=(0 1 1 0 1)
> > z4=(0 1 1 1 0)
> > z5=(1 0 0 1 1)
> > z6=(1 0 1 0 1)
> > z7=(1 0 1 1 0)
> > z8=(1 1 0 0 1)
> > z9=( 1 1 0 1 0)
> > z10=(1 1 1 0 0)
> >
> How can i generate them?
> then I would like to sum over z1, z2,....,z10 for something like (zi/3)+(1-zi)/8.
>
> Thanks.
- - - - - - - -
You still haven't made it clear what you mean by "sum over". Are you taking the sum separately along each column, or the sum of all the elements in each of the z's, or perhaps the sum of each row? Please make it clear what you are asking!

Assuming you mean the sum for each column, then each of the sums,

(zi/3)+(1-zi)/8 ,

would just be

(r-1)!*ell/ell!/(r-ell)! * (1/3-1/8) + r!/ell!/(r-ell)!/8

What could be easier?

If you actually want the set of z's generated for other purposes, see the FEX contribution by Jos:

http://www.mathworks.com/matlabcentral/fileexchange/7147-combn

Roger Stafford
From: yang on
I am sorry for confusion.

By sum over i mean the sum of each row. your answer will be changed?

Thanks
From: Roger Stafford on
"yang " <macmaster_egypt(a)yahoogroups.com> wrote in message <i1im84$41b$1(a)fred.mathworks.com>...
> I am sorry for confusion.
>
> By sum over i mean the sum of each row. your answer will be changed?
>
> Thanks
- - - - - - - - -
I had the strong impression that that was what ell meant, the sum of each row. That is, if you have a row of numbers which are each 0 or 1 and ell of them are 1, then their sum is bound to be ell. Tell me if I my impression was wrong. If so, what do you mean by ell?

Roger Stafford
From: Nathan on
On Jul 13, 2:36 pm, "yang " <macmaster_eg...(a)yahoogroups.com> wrote:
> I am sorry for confusion.
>
> By sum over i mean the sum of each row.  your answer will be changed?
>
> Thanks

A simple solution:

r = 5;
ell = 3;
count = 0;
for i=1:2^r-1
tmp = dec2bin(i,5)-'0';
if(sum(tmp)==ell)
count=count+1;
z(count,:) = tmp;
end
end
%%%%%%%%%%%
z =
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 0
1 0 0 1 1
1 0 1 0 1
1 0 1 1 0
1 1 0 0 1
1 1 0 1 0
1 1 1 0 0

-Nathan