help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Efficient definition of multidimensional ranges


From: Sergei Steshenko
Subject: Re: Efficient definition of multidimensional ranges
Date: Tue, 29 May 2012 03:16:36 -0700 (PDT)





>________________________________
> From: Doug Stewart <address@hidden>
>To: stn <address@hidden> 
>Cc: help-octave <address@hidden> 
>Sent: Tuesday, May 29, 2012 12:36 PM
>Subject: Re: Efficient definition of multidimensional ranges
> 
>
>
>
>
>On Tue, May 29, 2012 at 5:29 AM, stn <address@hidden> wrote:
>
>
>>
>>
>>
[snip]
>>
>>1   2   3
>>4   5   6
>>7    8    9   10   11   12
>>13   14
>>
>>the definition would be: 2 groups length 3, 1 group length 6, 1 group length 
>>2, counting from 1 to last, (whatever last may be)
>>
>>THX
>>stn
>>
>>
>>_______________________________________________
>>Help-octave mailing list
>>address@hidden
>>https://mailman.cae.wisc.edu/listinfo/help-octave
>>
>>
>Are you asking   "how to write a parser?"
>Doug
>
>
>-- 
>
>DAS
>


How about the following:



octave:1> foo{3}{1} = [1 2 3]
foo =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
  [1,3] =
  {
    [1,1] =

       1   2   3

  }
}
octave:2> foo{3}{2} = [4 5 6]
foo =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
  [1,3] =
  {
    [1,1] =

       1   2   3

    [1,2] =

       4   5   6

  }
}
octave:3> foo{6}{1} = [7 8 9 10 11 12]
foo =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
  [1,3] =
  {
    [1,1] =

       1   2   3

    [1,2] =

       4   5   6

  }
  [1,4] = [](0x0)
  [1,5] = [](0x0)
  [1,6] =
  {
    [1,1] =

        7    8    9   10   11   12

  }
}
octave:4> foo{2}{1} = [13 14]
foo =
{
  [1,1] = [](0x0)
  [1,2] =
  {
    [1,1] =

       13   14

  }
  [1,3] =
  {
    [1,1] =

       1   2   3

    [1,2] =

       4   5   6

  }
  [1,4] = [](0x0)
  [1,5] = [](0x0)
  [1,6] =
  {
    [1,1] =

        7    8    9   10   11   12

  }
}
octave:5> 


- I am using nested cell arrays, first index signifies number of elements, 
second index signifies an entry with given number of elements.


Regards,
  Sergei.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]