strange struct syntax

Francesco Potortì <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Organization CNR-ISTI, via Moruzzi 1, I-56124 Pisa, +39-0503153058
Message-ID <[email protected]>
I read the manual, and as far I understand, this is documented as it
is.  Yet, it looks very strange and adds to the difficulty of mastering
the syntax of cell arrays and structures, so I am asking for further
confirmation. 

Is this perfectly normal?


octave> a={"Name Surname"}
  a =
  {
    [1,1] = Name Surname
  }

octave> a(1)
  ans =
  {
    [1,1] = Name Surname
  }

## Now, I want to create a struct with only one field, which is a cell
## array of strings.

## This one works alright
octave> clear s
octave> s.names = a(1)
  s =
    scalar structure containing the fields:
      names =
      {
        [1,1] = Name Surname
      }

## This one does not.  The manual explains why
octave> s = struct("names", a(1))
  s =
    scalar structure containing the fields:
      names = Name Surname

## This one does what I want.  Completely  unintuitive to me
octave> s = struct("names", { a(1) })
  s =
    scalar structure containing the fields:
      names =
      {
        [1,1] = Name Surname
      }

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(gate 20, 1st floor, room C71)         Web:    http://fly.isti.cnr.it
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.