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:
How to Create a Matrix Of Couple Of Numbers

Subject: How to Create a Matrix Of Couple Of Numbers

From: agibulu

Date: 12 Mar, 2009 14:57:55

Message: 1 of 13

Hi to everybody! I have a question for you. I have to create a matlab program to build a matrix. The matrix has to be 24528 x 2 (rows x columns). I have to put in every row a couple of int in this order:
1,1
1,2
1,3
1,4
1,5
1,6
2,2
2,3
2,4
2,5
2,6
3,3
3,4
3,5
3,6
4,4
4,5
4,6
5,5
5,6
6,6
then i have to do the same thing with number from 9 to 14: 9,9; 9,10; 9,11; 9,12; 9,13; 9,14; 10,10; 10,11; 10,12; 10,13; 10,14; 11,11; 11,12; 11,13; 11,14; 12,12; 12,13; 12,14; 13,13; 13,14; 14,14.
then with numbers from 17 to 24 etc etc.
I hope you have understand my task. Any idea?

Subject: How to Create a Matrix Of Couple Of Numbers

From: someone

Date: 12 Mar, 2009 15:08:01

Message: 2 of 13

agibulu <sdad@adsda.com> wrote in message <23549493.1236869905758.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hi to everybody! I have a question for you. I have to create a matlab program to build a matrix. The matrix has to be 24528 x 2 (rows x columns). I have to put in every row a couple of int in this order:
> 1,1
> 1,2
> 1,3
> 1,4
> 1,5
> 1,6
> 2,2
> 2,3
> 2,4
> 2,5
> 2,6
> 3,3
> 3,4
> 3,5
> 3,6
> 4,4
> 4,5
> 4,6
> 5,5
> 5,6
> 6,6
> then i have to do the same thing with number from 9 to 14: 9,9; 9,10; 9,11; 9,12; 9,13; 9,14; 10,10; 10,11; 10,12; 10,13; 10,14; 11,11; 11,12; 11,13; 11,14; 12,12; 12,13; 12,14; 13,13; 13,14; 14,14.
> then with numbers from 17 to 24 etc etc.
> I hope you have understand my task. Any idea?

Take a look at (and read) the MATLAB "Getting Started" documentation.
It should answer all your questions.

Subject: How to Create a Matrix Of Couple Of Numbers

From: Roger Stafford

Date: 12 Mar, 2009 15:41:01

Message: 3 of 13

agibulu <sdad@adsda.com> wrote in message <23549493.1236869905758.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hi to everybody! I have a question for you. I have to create a matlab program to build a matrix. The matrix has to be 24528 x 2 (rows x columns). I have to put in every row a couple of int in this order:
> 1,1
> 1,2
> 1,3
> 1,4
> 1,5
> 1,6
> 2,2
> 2,3
> 2,4
> 2,5
> 2,6
> 3,3
> 3,4
> 3,5
> 3,6
> 4,4
> 4,5
> 4,6
> 5,5
> 5,6
> 6,6
> then i have to do the same thing with number from 9 to 14: 9,9; 9,10; 9,11; 9,12; 9,13; 9,14; 10,10; 10,11; 10,12; 10,13; 10,14; 11,11; 11,12; 11,13; 11,14; 12,12; 12,13; 12,14; 13,13; 13,14; 14,14.
> then with numbers from 17 to 24 etc etc.
> I hope you have understand my task. Any idea?

  I have _not_ understood your task. The first set of numbers range from 1 to 6, the second set from 9 to 14, and the third from 17 to 24. The first value jumps by 8 each time but the second jumps first by 8, then by 10. What is the pattern there?

  I suspect that the 'nchoosek' function will be used somehow but I can't tell in what way precisely until you reveal how your intervals are to be selected.

Roger Stafford

Subject: How to Create a Matrix Of Couple Of Numbers

From: agibulu

Date: 12 Mar, 2009 16:03:32

Message: 4 of 13

sorry i made a mistake in the first post. My range of numbers are: 1-6; 9-14; 17-22; etc etc
i have to take 292 number groups of 8 and consider only the first 6 numbers for each group.

Subject: How to Create a Matrix Of Couple Of Numbers

From: agibulu

Date: 12 Mar, 2009 16:00:51

Message: 5 of 13

a little help? i started with some for cycle but it's wrong.

MATRIX=zeros(42,2); %(lets start with 2 groups of 21 couples)
for k=0:1
    for t=1+21*k:21+21*k
        for i=1+8*k:6+8*k
            for j=1+8*k:6+8*k
                if j>=i
                    MATRIX(t,:)=[i,j];
                end
            end
        end
    end
end

the inner cycles are obiousvly wrong but the outer ones is good i think

Subject: How to Create a Matrix Of Couple Of Numbers

From: Roger Stafford

Date: 12 Mar, 2009 16:53:03

Message: 6 of 13

agibulu <sdad@adsda.com> wrote in message <16812913.1236873846162.JavaMail.jakarta@nitrogen.mathforum.org>...
> sorry i made a mistake in the first post. My range of numbers are: 1-6; 9-14; 17-22; etc etc
> i have to take 292 number groups of 8 and consider only the first 6 numbers for each group.

  You can generate a first group of 21 using 'nchoosek' and then successively add multiples of 8 to those results.

 N = 1168; % N = 24528/21 (or is it N = 292?)
 m = nchoosek(0:6,2);
 m(:,1) = m(:,1) + 1; % This gives the first group of 21
 t = repmat(reshape(repmat((0:8:8*(N-1)).',1,21).',[],1),1,2);
 m = repmat(m,N,1)+t;
 
Roger Stafford

Subject: How to Create a Matrix Of Couple Of Numbers

From: agibulu

Date: 12 Mar, 2009 17:32:39

Message: 7 of 13

GREAT!!!! YOU ROCK!!!
It's exactly what i'm looking for.
What have you done?
Let me explain exactly what i am doing (with your precious help). I have to build a matrix with 24528 rows. The first 6132 ones are exactly what you have produced in your code (probabily the number of rows isn't correct but i think that i have only to modify the N parameter, isn't it?).
For the other 18396 rows i have to use the two numbers of each groups of 8 that i didn't use in the first session: so 7,8 for the first, 15,16 for the second etc etc. But now i don't have to make couple of number in the same earlier order. Infact it's perfect if i create couples of numbers which come from different octets. For example 8,16; 15,23; etc etc. do you understand?
another help? ;-)

Subject: How to Create a Matrix Of Couple Of Numbers

From: sassiric

Date: 14 Mar, 2009 11:00:51

Message: 8 of 13

help me Roger! Please!

Subject: How to Create a Matrix Of Couple Of Numbers

From: Roger Stafford

Date: 15 Mar, 2009 02:50:02

Message: 9 of 13

agibulu <sdad@adsda.com> wrote in message <9187183.1236879190424.JavaMail.jakarta@nitrogen.mathforum.org>...
> ......
> For the other 18396 rows i have to use the two numbers of each groups of 8 that i didn't use in the first session .......

  I need a more detained explanation of what you are doing with the other 18396 rows. Give some concrete examples of how the pairs should look using 7,8,15,16, etc. As things stand I don't know what you want.

Roger Stafford

Subject: How to Create a Matrix Of Couple Of Numbers

From: Image Analyst

Date: 15 Mar, 2009 03:31:01

Message: 10 of 13

sassiric <sdad@adsda.com> wrote
> help me Roger! Please!
-----------------------------------------------------------------------------------------------------

sassiric:
Well Roger is very, very good but I don't believe he's a mind reader. He was answering agibulu's question and now you barge in asking him for help, without even stating your question. Well why don't you start your own thread with your own question?

Subject: How to Create a Matrix Of Couple Of Numbers

From: Roger Stafford

Date: 15 Mar, 2009 03:58:01

Message: 11 of 13

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gphspk$j1t$1@fred.mathworks.com>...
> sassiric:
> Well Roger is very, very good but I don't believe he's a mind reader. He was answering agibulu's question and now you barge in asking him for help, without even stating your question. Well why don't you start your own thread with your own question?

  Thanks for the praise, Image Analyst. However, in this case I think you'll find that "Agibulu" and "Sassiric" are designations for the same person, or at least they have the same email address: <sdad@adsda.com>. Under the latter designation the OP is referring to the questions already asked about the remaining 18396 rows under the former designation. I do wish users would stick to the same name at least throughout any one given thread.

Roger Stafford

Subject: How to Create a Matrix Of Couple Of Numbers

From: sassiric

Date: 15 Mar, 2009 09:39:12

Message: 12 of 13

i need to make couples of numbers with 7,8,15,16,23,24,31,32,39,40,47,48 etc etc until 2336. I need to fill 18396 rows with those couples.
the couples have to be with numbers contained in different octects, for example: 7,23; 8,23; 39,48; 32,80;
the task is to create a "small" set with numbers 7,8,15,16,23,24,31,32,39,40,47,48 etc. infact if i consider all the couples which i can create with these numbers i have too much couples. I have to create a random subspace which is made of numbers listed before and where each couple is made of numbers taken from different octects. As you know octects is made of 8 numbers, 6 of them used in the first task and the other 2 is used now. the couples 7,23; 39,48; 72,80; 80,1535 are perfect, the couples 7,7; 7,8; 1471,1471; 1471,1472 are bad. i hope you understand.

Subject: How to Create a Matrix Of Couple Of Numbers

From: sassiric

Date: 17 Mar, 2009 09:47:39

Message: 13 of 13

Sorry, i made a mistake again. Forget the earlier post. My second task is to attach a second matrix to the first one generated before.
The new matrix has to produce couple of numbers coming from different octects but with the first 6 numbers of each octects and not with the last two as i wrote in the last post. Do you understand? for example i have to produce couple like these:
1,9
1,10
1,11
1,12
1,13
1,14
2,9
2,10
2,11
2,12
..
but if we consider all the couples we'll obtain an extra large number that is too big. So we have to make a cut and consider "only" 18396 random rows. A perfect thing is to obtain 18396 rows that are composed by couples of numbers which involve all the octects. So if i can choose from 1,9; 1,10; 1,11; 1,12; 1,13; 1,14 and 1,9; 17,77; 113,259; 306,358; 409,507; 713,1077 i prefer the second one cause i can consider more octects than the first one. I hope that you understand my task and i want to say and extra "THANK YOU" for your patience.

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