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: Robert Walton
Subject: Re: equivalent for C-style init: structname varname[] = {...}
Date: Thu, 15 Nov 2012 12:20:35 -0500

> 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
> );

> s(1)

> What am I doing wrong, then?

The dimension argument (the "4" above) to cell2struct is wrong.  I think you'll get what you want if you make it 2.  It is which matrix subscript to use, not the number of elements.

reply via email to

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