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


On Fri, Feb 26, 2010 at 11:21 AM,  <n...@itimes.com> wrote:
> Hi all.
>
> Please refer the following octave code.
>
> cdf = netcdf('glo_att.nc','c');
> date='23-Feb-2010';
> cdf.CREATION_DATE = date;
> cdf.history = 'netcdf file created in octave';
> cdf('lon') = 4;
> cdf('lat') = 2;
> cdf{'var'} =  ncchar('lon','lat');
> cdf{'var'}.Time = 'Today';
> N=5;
> cdf{'var'}.['NOTE_',int2str(N)] = 'This is fifth note';
> ncclose(cdf)
>
> Here I want to add "NOTE_5" as an atribute to "var" variable. Though I could 
> have simply done it with
> cdf{'var'}.NOTE_5;
> which would work, the thing is N keeps changing.
>
> Can anyone please suggest some way?
>
> Thanks.
>
> Nands
>
> ------------------------------------------------------------------------------
> 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
>

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