help-octave
[Top][All Lists]
Advanced

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

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


From: Jordi Gutiérrez Hermoso
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Mon, 12 Nov 2012 11:30:41 -0500

On 12 November 2012 11:09, Yury T. <address@hidden> wrote:
> I can't find or figure out an equivalent for the C-style variable
> initialization in Octave:
>
> structname varname[] = { {<field1_value>,<field2_value>},
> {<field1__value>,<field2_value>} };

The struct command can do struct arrays:

    s = struct ("field1", {value1, value2}, "field2", {value3, value4})

Note that indexing a struct array with the field name will give you
cs-lists, however:

    s.field1
    s.field2

People often find cs-lists confusing because they cannot be assigned
to another variable and they get passed in a funny way in function
calls. If you cannot understand the explanation for cs-lists in the
manual, please let me know so we can improve the manual.

HTH,
- Jordi G. H.


reply via email to

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