[Top][All Lists]

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

Re: equivalent for C-style init: structname varname[] = {...} ?

From: Yury T.
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Wed, 14 Nov 2012 07:18:32 -0800 (PST)

Jordi Gutiérrez Hermoso-2 wrote
> I insist that the cell2struct solution I presented here solves your
> problem:
> You have already rejected it, but I don't know on what grounds.

I preferred Sergei's solution over yours (not "rejected" yours) on the
grounds of Sergei's solution allowing both simple iteration over full range
of items ("for each item in array do smth.") and simple selective access to
items by key of arbitrary type ("select item with ID=anything"). I will need
both, when I think of it, not only full range iteration.

Also, this adaptation of your snippet doesn't work, saying "error:
cell2struct: number of FIELDS does not match dimension":

s = cell2struct(

  "Buffat+Borel 1976 (5)", "Buffat+Borel 1976 (5)", 13, 1337;
  "Lai+Guo+Petrova+ 1996 (2a)", "Lai+Guo+Petrova+ 1996 (2a)", 30, 505

  { "ID", "data", "Xo", "Yo" }, 4


What am I doing wrong, then?

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

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