Thread Subject: Permuation

Subject: Permuation

From: Chirackel Yoonus

Date: 18 May, 2009 10:54:01

Message: 1 of 7

Hi,
I want to create matrix of permutations of two number {1,-1}.
for N=2 , I have 2^2 = 4 different paths, the matrix contains 2^n rows and n columns.
1 1
1 -1
-1 1
-1 -1
for n=3, we have 8 rows and 3 columns
1 1 1
1 1 -1
1 - 11
1 - 1-1
-1 1 1
-1 1 -1
-1 - 1 1
-1 -1 -1
Is there any standard algorithm to generate it

Thanks
Yoonus

Subject: Permuation

From: Jos

Date: 18 May, 2009 11:23:01

Message: 2 of 7

"Chirackel Yoonus" <yoonus@ifmr.ac.in> wrote in message <gureo9$b24$1@fred.mathworks.com>...
> Hi,
> I want to create matrix of permutations of two number {1,-1}.
> for N=2 , I have 2^2 = 4 different paths, the matrix contains 2^n rows and n columns.
> 1 1
> 1 -1
> -1 1
> -1 -1
> for n=3, we have 8 rows and 3 columns
> 1 1 1
> 1 1 -1
> 1 - 11
> 1 - 1-1
> -1 1 1
> -1 1 -1
> -1 - 1 1
> -1 -1 -1
> Is there any standard algorithm to generate it
>
> Thanks
> Yoonus

see COMBN
http://www.mathworks.com/matlabcentral/fileexchange/7147

combn([-1 1],3)

Jos

Subject: Permuation

From: Bruno Luong

Date: 18 May, 2009 11:47:01

Message: 3 of 7

The combination is Cartesian product of sets, which can be derived using NDGRID

n=3;
c(1:n)={[-1 1]};
[c{:}]=ndgrid(c{:});
c=reshape(cat(n+1,c{:}),[],n)

% Bruno

Subject: Permuation

From: Chirackel Yoonus

Date: 18 May, 2009 12:03:02

Message: 4 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gurhrl$qi4$1@fred.mathworks.com>...
> The combination is Cartesian product of sets, which can be derived using NDGRID
>
> n=3;
> c(1:n)={[-1 1]};
> [c{:}]=ndgrid(c{:});
> c=reshape(cat(n+1,c{:}),[],n)
>
> % Bruno

Dear Jos ,
 thanks it is working fine

Dear Bruno,
i get a error for when n=4

Subject: Permuation

From: Bruno Luong

Date: 18 May, 2009 12:08:01

Message: 5 of 7

"Chirackel Yoonus" <yoonus@ifmr.ac.in> wrote in message <guripm$pp8$1@fred.mathworks.com>...

> Dear Bruno,
> i get a error for when n=4

Not because n=4, but because c needed to be clear when there is a previous run.

clear c % <-

n=4;
c(1:n)={[-1 1]};
[c{:}]=ndgrid(c{:});
c=reshape(cat(n+1,c{:}),[],n)

Bruno

Subject: Permuation

From: Chirackel Yoonus

Date: 4 Jun, 2009 10:44:02

Message: 6 of 7

"Jos " <#10584@fileexchange.com> wrote in message <gurgel$qhn$1@fred.mathworks.com>...
> "Chirackel Yoonus" <yoonus@ifmr.ac.in> wrote in message <gureo9$b24$1@fred.mathworks.com>...
> > Hi,
> > I want to create matrix of permutations of two number {1,-1}.
> > for N=2 , I have 2^2 = 4 different paths, the matrix contains 2^n rows and n columns.
> > 1 1
> > 1 -1
> > -1 1
> > -1 -1
> > for n=3, we have 8 rows and 3 columns
> > 1 1 1
> > 1 1 -1
> > 1 - 11
> > 1 - 1-1
> > -1 1 1
> > -1 1 -1
> > -1 - 1 1
> > -1 -1 -1
> > Is there any standard algorithm to generate it
> >
> > Thanks
> > Yoonus
>
> see COMBN
> http://www.mathworks.com/matlabcentral/fileexchange/7147
>
> combn([-1 1],3)
>
> Jos


I get the error when I tried to check for combn([-1,1],21).. I am looking for N = 32?
Please help me out solving this error.

Thanks
Yoonus

Subject: Permuation

From: Jos

Date: 4 Jun, 2009 10:55:03

Message: 7 of 7

"Chirackel Yoonus" <yoonus@ifmr.ac.in> wrote in message <h088hi$e1l$1@fred.mathworks.com>...
..
> I get the error when I tried to check for combn([-1,1],21).. I am looking for N = 32?
> Please help me out solving this error.

I assume you get a memory error ... Have you calculated how much memory a (2^N) * N double array occupies?

Jos

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
combn Chirackel Yoonus 4 Jun, 2009 06:49:03
repeated numbers Chirackel Yoonus 18 May, 2009 06:59:04
perumation Chirackel Yoonus 18 May, 2009 06:59:04
rssFeed for this Thread

Contact us at files@mathworks.com