On Thu, Mar 18, 2010 at 3:20 PM, Jaroslav Hajek <high...@gmail.com> wrote:
> On Thu, Mar 18, 2010 at 3:02 PM, Alexander Barth
> <barth.alexan...@gmail.com> wrote:
>> you could do this like this:
>>
>> setfield(cdf{'var'},['NOTE_',int2str(N)],'This is fifth note')
>>
>> setfield allows you to add fields whose names are determined at
>> run-time to a struct. It also works for addition attributes in octcdf.
>> Another way could be the use of eval. But it is a good idea to avoid
>> eval if possible.
>>
>> Cheers,
>> Alex
>>
>
> Actually, even setfield is sort of deprecated. You should be able to
> use a dynamic field reference directly:
>
> cdf{'var'}.(['NOTE_',int2str(N)]) = 'This is fifth note';
>
> Note the extra parentheses, they're needed.
>

Interesting! I did not know this syntax. I tested it with octcdf and it works.

Regards
Alex

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to