help-octave
[Top][All Lists]
Advanced

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

numel(foo{:}) - feature or bug ?


From: Sergei Steshenko
Subject: numel(foo{:}) - feature or bug ?
Date: Fri, 5 Aug 2011 04:23:47 -0700 (PDT)

Hello,

first here is screen output of 'help numel' in octave-3.4.2:

"
octave:1> help numel
`numel' is a built-in function

 -- Built-in Function:  numel (A)
 -- Built-in Function:  numel (A, IDX1, IDX2, ...)
     Return the number of elements in the object A.  Optionally, if
     indices IDX1, IDX2, ... are supplied, return the number of
     elements that would result from the indexing

           A(IDX1, IDX2, ...)

     This method is also called when an object appears as lvalue with
     cs-list indexing, i.e., `object{...}' or `object(...).field'.

     See also: size



Additional help for built-in functions and operators is
available in the on-line version of the manual.  Use the command
`doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the address@hidden
mailing list.
octave:2>
".

And here is a simple/sample screen session:

"
octave:2> foo{1} = "a"
foo =
{
  [1,1] = a
}
octave:3> foo{2} = "ab"
foo =
{
  [1,1] = a
  [1,2] = ab
}
octave:4> foo{3} = "abc"
foo =
{
  [1,1] = a
  [1,2] = ab
  [1,3] = abc
}
octave:5> foo{4} = [1 2 3 4; 5 6 7 8; 9 10 11 12]
foo =
{
  [1,1] = a
  [1,2] = ab
  [1,3] = abc
  [1,4] =

      1    2    3    4
      5    6    7    8
      9   10   11   12

}
octave:6> numel(foo{:})
ans =  72
octave:7> 
".

Can anybody please explain the '72' number ? Specifically, based on the
above 'help numel' output ?

If there are indeed 72 elements, can anybody please list _each_ element ?

...

A simpler (?) case:

octave:1> bar{1} = "d"
bar =
{
  [1,1] = d
}
octave:2> bar{2} = "de"
bar =
{
  [1,1] = d
  [1,2] = de
}
octave:3> bar{3} = "def"
bar =
{
  [1,1] = d
  [1,2] = de
  [1,3] = def
}
octave:4> numel(bar{:})
ans =  6
octave:5> 

- this case is easier to explain, but I think the explanation will
contradict the "foo" case.

Anyway, I just have a vague idea for the "bar" case.

Thanks,
  Sergei.




reply via email to

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