f



How to get combinations of a matrix

hello,

I have R=[ 0 1 1 0 ]
means 2 number are there and 4 places in R.

I need 16 different R combinations.

can anyone help me???

Thanks
Ankur
0
joank2001 (1)
11/11/2004 3:47:08 PM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

4 Replies
1320 Views

Similar Articles

[PageSpeed] 5

Ankur Garg wrote:
>
>
> hello,
>
> I have R=[ 0 1 1 0 ]
> means 2 number are there and 4 places in R.
>
> I need 16 different R combinations.
>
> can anyone help me???
>
> Thanks
> Ankur

I'm not sure if I've understood your assignment properly, but this
gives an interesting output that might be sort of what you want.

str2num(reshape([reshape(dec2bin(0:15)',1,64);
char(ones(1,64)*32)],8,16)')
0
11/11/2004 4:05:04 PM
Steve Amphlett wrote:
>
>
<snip, badly chopped code post...

Hopefully this won't be chopped.

str2num(reshape([reshape(...
    dec2bin(0:15)',1,64);...
    char(ones(1,64)*32)],8,16)')
0
11/11/2004 4:07:15 PM
Steve Amphlett wrote:
>
>
> Steve Amphlett wrote:
>>
>>
> <snip, badly chopped code post...
>
> Hopefully this won't be chopped.
>
> str2num(reshape([reshape(...
> dec2bin(0:15)',1,64);...
> char(ones(1,64)*32)],8,16)')

All combinations for p places, s of them are set (one) can be
obtained as follows:

A=dec2bin(0:2^p-1)-'0';
A=A(sum(A,2)==s,:);

It is quite related to this MATLAB contest, moving furniture problem.
0
y.cao (356)
11/12/2004 8:55:56 AM
Yi Cao wrote:
>
>
<snip, textbook homework answer...

Couldn't you have obfuscated it just a little bit :-)

- Steve
0
11/12/2004 9:10:03 AM
Reply: