help-octave
[Top][All Lists]
Advanced

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

Re: Is modifying structures using a string possible?


From: Sergei Steshenko
Subject: Re: Is modifying structures using a string possible?
Date: Fri, 5 Oct 2012 15:03:40 -0700 (PDT)




----- Original Message -----
> From: injoi <address@hidden>
> To: address@hidden
> Cc: 
> Sent: Friday, October 5, 2012 11:28 PM
> Subject: Is modifying structures using a string possible?
> 
> Is it possible to modify a structure so that its field names are defined by
> inputs in a string?
> 
> example:
> 
> eString = {'dogs','cats','birds'};
> 
> for i = 1:length(eString)
> 
> animals.eString(i) = i;
> end
> 
> *then the desired output would be..
> animals.dogs = 1
> animals.cats = 2
> animals.birds = 3
> 
> I have been trying do this for a while with no luck. Any suggestions?
> 
> 
> 
> -----
> Windows 7, intel Xeon(R) 3.3GHz
> 
> Thanks, Nohtal
> --
>


Yes, it is possible. Consult Matlab (on their site) documentation for 
'setfield'.

Regards,
  Sergei.


reply via email to

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