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:
one to many mapping matrix

Subject: one to many mapping matrix

From: Kate

Date: 29 Sep, 2010 02:35:11

Message: 1 of 5

Hi guys,

Asking for a bit of help.

I have a matrix :

Matrix = [ 100 200 300 400
                500 400 600 700
                800 900 500 200]

I basically want to form a new matrix that looks like:

New_Matrix = [ 500 400 300 400
                      800 900 300 400
                      100 200 600 700
                      800 900 600 700
                      100 200 500 200
                      500 400 500 200]

So basically :

in 'Matrix' , {300 400} maps to {500 400} & { 800 900}
similarly, {600 700} maps to {100 200) & {800 900}
and, {500 200} maps to {100 200} & {500 400}


I'd like to be able to get some help in creating a solution to form the "New_Matrix".
Please note that in my dataset , the input data , i.e. "Matrix", has potential to be large , so my code can't be limited to the example "Matrix" I used here.

thanks
kate
  


                     

Subject: one to many mapping matrix

From: Roger Stafford

Date: 29 Sep, 2010 03:32:19

Message: 2 of 5

"Kate " <chino_tones@hotmail.com> wrote in message <i7u8ku$1h2$1@fred.mathworks.com>...
> Hi guys,
>
> Asking for a bit of help.
>
> I have a matrix :
>
> Matrix = [ 100 200 300 400
> 500 400 600 700
> 800 900 500 200]
>
> I basically want to form a new matrix that looks like:
>
> New_Matrix = [ 500 400 300 400
> 800 900 300 400
> 100 200 600 700
> 800 900 600 700
> 100 200 500 200
> 500 400 500 200]
>
> So basically :
>
> in 'Matrix' , {300 400} maps to {500 400} & { 800 900}
> similarly, {600 700} maps to {100 200) & {800 900}
> and, {500 200} maps to {100 200} & {500 400}
>
>
> I'd like to be able to get some help in creating a solution to form the "New_Matrix".
> Please note that in my dataset , the input data , i.e. "Matrix", has potential to be large , so my code can't be limited to the example "Matrix" I used here.
>
> thanks
> kate
- - - - - - - -
  When it comes to larger matrices, you need to explain how your "mapping' generalizes. Do you always have four columns or is the number of columns even? Do you care about the order of rows in New_Matrix? If your matrix has n rows, will New_Matrix always have n*(n-1) rows? Questions of that kind.

  And finally can you show us what you have already done to solve this problem? Providing you help should not be the same thing as doing it all for you in a tidy package.

Roger Stafford
                 

Subject: one to many mapping matrix

From: Kate

Date: 29 Sep, 2010 03:54:04

Message: 3 of 5

Hi Roger,

Of course I'd post whatever I did to get towards the solution but unfortunately I dont even know where u start in solving the solution.

Assuming Matrix size increases as follows:

Matrix = [ 100 200 300 400
                500 400 600 700
                800 900 500 200
                450 350 250 950]

The "New_matrix" should look like:

New_Matrix = [ 500 400 300 400
                      800 900 300 400
                      450 350 300 400
                      100 200 600 700
                      800 900 600 700
                      450 350 600 700
                      100 200 500 200
                      500 400 500 200
                      450 350 500 200
                      100 200 250 950
                      500 400 250 950
                      800 900 250 950 ]

Yes, there is always four columns . Also, the ordering of rows doesn't matter for "New_Matrix".

thanks
kate

Subject: one to many mapping matrix

From: Roger Stafford

Date: 29 Sep, 2010 05:37:04

Message: 4 of 5

"Kate " <chino_tones@hotmail.com> wrote in message <i7ud8s$rph$1@fred.mathworks.com>...
> .......
> Of course I'd post whatever I did to get towards the solution but unfortunately I dont even know where u start in solving the solution.
> .......
- - - - - - - - - -
  Well I have this solution banging around in my head so I might as well give it to you. I made that comment about showing us your work because I had hoped you would see the similarity between this problem and the other one which you called "looping issue". They both involve a similar mapping from n things to n*(n-1) things.

 n = size(M,1); % Where M is your "Matrix"
 p = (1:n^2).';
 p(1:n+1:n^2) = [];
 [I,J] = ind2sub([n,n],p);
 N = [M(I,1:2),M(J,3:4)]; % Where N is your "New_Matrix"

Roger Stafford

Subject: one to many mapping matrix

From: Kate

Date: 30 Sep, 2010 02:59:08

Message: 5 of 5

thanks a lot roger.....once again


kate

Tags for this Thread

No tags are associated with 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