Got Questions? Get Answers.
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:
constructing indices

Subject: constructing indices

From: raj

Date: 23 Oct, 2011 16:44:41

Message: 1 of 4

Hello all,
To the following indices order, how the third indices work?

(1, 1, 1)
(2, 1, 1)
(3, 1, 2)
(1, 2, 2)
(2, 2, 3)
(3, 2, 3)
(1, 3, 4)
(2, 3, 4)
(3, 3, 5)
(1, 4, 5)
(2, 4, 6)
(3, 4, 6)
(1, 5, 7)
(2, 5, 7)
(3, 5, 8)
(1, 6, 8)
(2, 6, 9)
(3, 6, 9)

Appreciate your help.
R
......

Subject: constructing indices

From: Nasser M. Abbasi

Date: 23 Oct, 2011 17:16:02

Message: 2 of 4

On 10/23/2011 11:44 AM, raj wrote:
> Hello all,
> To the following indices order, how the third indices work?
>
> (1, 1, 1)
> (2, 1, 1)
> (3, 1, 2)
> (1, 2, 2)
> (2, 2, 3)
> (3, 2, 3)
> (1, 3, 4)
> (2, 3, 4)
> (3, 3, 5)
> (1, 4, 5)
> (2, 4, 6)
> (3, 4, 6)
> (1, 5, 7)
> (2, 5, 7)
> (3, 5, 8)
> (1, 6, 8)
> (2, 6, 9)
> (3, 6, 9)
>
> Appreciate your help.
> R
> ......

Not sure what you mean by " how the third indices work?".

Work in what sense?

I think of a 3D matix as a book.
2D matrix as page in the book.
and 1D matrix as a row or a column on page.

So, (3, 1, 2) means the third line, in the first column on the second page of the book.
and (3, 6, 9) means the third line, in the 6th column on the 9th page of the book.

and so on

--Nasser

Subject: constructing indices

From: raj

Date: 23 Oct, 2011 17:32:59

Message: 3 of 4

On Oct 23, 11:16 am, "Nasser M. Abbasi" <n...@12000.org> wrote:
> On 10/23/2011 11:44 AM, raj wrote:
>
>
>
>
>
>
>
>
>
> > Hello all,
> > To the following indices order, how the third indices work?
>
> > (1, 1, 1)
> > (2, 1, 1)
> > (3, 1, 2)
> > (1, 2, 2)
> > (2, 2, 3)
> > (3, 2, 3)
> > (1, 3, 4)
> > (2, 3, 4)
> > (3, 3, 5)
> > (1, 4, 5)
> > (2, 4, 6)
> > (3, 4, 6)
> > (1, 5, 7)
> > (2, 5, 7)
> > (3, 5, 8)
> > (1, 6, 8)
> > (2, 6, 9)
> > (3, 6, 9)
>
> > Appreciate your help.
> > R
> > ......
>
> Not sure what you mean by " how the third indices work?".
>
> Work in what sense?
>
> I think of a 3D matix as a book.
> 2D matrix as page in the book.
> and 1D matrix as a row or a column on page.
>
> So, (3, 1, 2) means the third line, in the first column on the second page of the book.
> and (3, 6, 9) means the third line, in the 6th column on the 9th page of the book.
>
> and so on
>
> --Nasser

Thanks Nasser.
I have the code:
p = 0;
for j = 1:3;
    for i = 1:3;
      p = p+1;
     if (mod(p,2)==1)
          [i j p]
      else
          [i j p-1]
      end
     end
end

It produces
(1, 1, 1)
(2, 1, 1)
(3, 1, 3)
(1, 2, 3)
(2, 2, 5)
(3, 2, 5) and so on.

But I want to get the following.
(1, 1, 1)
(2, 1, 1)
(3, 1, 2)
(1, 2, 2)
(2, 2, 3)
(3, 2, 3) and so on.

Thanks,
R

Subject: constructing indices

From: Roger Stafford

Date: 23 Oct, 2011 18:39:13

Message: 4 of 4

raj <rajkrai@gmail.com> wrote in message <0b8e491f-5983-4634-88a7-4479df9862bc@31g2000prp.googlegroups.com>...
> Hello all,
> To the following indices order, how the third indices work?
>
> (1, 1, 1)
> (2, 1, 1)
> (3, 1, 2)
> (1, 2, 2)
> (2, 2, 3)
> (3, 2, 3)
> (1, 3, 4)
> (2, 3, 4)
> (3, 3, 5)
> (1, 4, 5)
> (2, 4, 6)
> (3, 4, 6)
> (1, 5, 7)
> (2, 5, 7)
> (3, 5, 8)
> (1, 6, 8)
> (2, 6, 9)
> (3, 6, 9)
>
> Appreciate your help.
> R
> ......
- - - - - - - - -
  It's not clear to me how and if you want this generalized. The following works just for your particular request.

 t = (0:17).';
 A = [mod(t,3),floor(t/3),floor(t/2)]+1;

Perhaps it will give you ideas for generalizing.

Roger Stafford

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