Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Combinatioral Matrix

Subject: Combinatioral Matrix

From: SULE

Date: 10 Oct, 2012 08:50:08

Message: 1 of 3

Hello,
I need to create a matrix seems this

                      x1 .................... x6 ................... x12 (variable)
 1 1 1 1 1 1 1 1 1 0 0 0 0
 2 1 1 1 1 1 1 1 0 1 0 0 0
. . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
C(m,n)=495 0 0 0 0 1 1 1 1 1 1 1 1 1

 m= # of variable =12= # of columns
 n =# of constraint = 8
c(m,n) = # of rows
c(12,8) = 495
There should be a combination to create a matrix includes in a row, eight '1' and four'0'.
I am very new at MATLAB. If you can help me, I will appreciate.

Sule ERYURUK

Subject: Combinatioral Matrix

From: Roger Stafford

Date: 10 Oct, 2012 18:38:09

Message: 2 of 3

"SULE" wrote in message <k53cs0$agp$1@newscl01ah.mathworks.com>...
> Hello,
> I need to create a matrix seems this
>
> x1 .................... x6 ................... x12 (variable)
> 1 1 1 1 1 1 1 1 1 0 0 0 0
> 2 1 1 1 1 1 1 1 0 1 0 0 0
> . . . . . . . . . . . . . .
> . . . . . . . . . . . . . . . . . .
> C(m,n)=495 0 0 0 0 1 1 1 1 1 1 1 1 1
>
> m= # of variable =12= # of columns
> n =# of constraint = 8
> c(m,n) = # of rows
> c(12,8) = 495
> There should be a combination to create a matrix includes in a row, eight '1' and four'0'.
> I am very new at MATLAB. If you can help me, I will appreciate.
>
> Sule ERYURUK
- - - - - - - - - -
 P = nchoosek(1:m,n);
 r = size(P,1);
 C = zeros(r,m);
 C(sub2ind(size(C),repmat((1:r)',n,1),P(:))) = 1;

Roger Stafford

Subject: Combinatioral Matrix

From: SULE

Date: 11 Oct, 2012 04:35:10

Message: 3 of 3

"Roger Stafford" wrote in message <k54fah$k24$1@newscl01ah.mathworks.com>...
> "SULE" wrote in message <k53cs0$agp$1@newscl01ah.mathworks.com>...
> > Hello,
> > I need to create a matrix seems this
> >
> > x1 .................... x6 ................... x12 (variable)
> > 1 1 1 1 1 1 1 1 1 0 0 0 0
> > 2 1 1 1 1 1 1 1 0 1 0 0 0
> > . . . . . . . . . . . . . .
> > . . . . . . . . . . . . . . . . . .
> > C(m,n)=495 0 0 0 0 1 1 1 1 1 1 1 1 1
> >
> > m= # of variable =12= # of columns
> > n =# of constraint = 8
> > c(m,n) = # of rows
> > c(12,8) = 495
> > There should be a combination to create a matrix includes in a row, eight '1' and four'0'.
> > I am very new at MATLAB. If you can help me, I will appreciate.
> >
> > Sule ERYURUK
> - - - - - - - - - -
> P = nchoosek(1:m,n);
> r = size(P,1);
> C = zeros(r,m);
> C(sub2ind(size(C),repmat((1:r)',n,1),P(:))) = 1;
>
> Roger Stafford

''''''''''''''''''''''''''''''''''''''''''''''''''''''
Thank you very much for your response Mr. Stafford .
It is way I was really looking for.



Sule ERYURUK

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us