Prev: plot figure won't appear
Next: correlation matrix
From: Bo on 13 Jul 2010 16:21 Hi All I am trying to use function eval to a structure variable. For sake of simplicity, first create a structure sv as sv.f1=5; sv.f2=6; The question is I can't access the fields of sv using eval('sv').f1 Any suggestion? Thanks in advance.
From: someone on 13 Jul 2010 16:39 "Bo " <b.wang(a)warwick.ac.uk> wrote in message <i1ihrh$e44$1(a)fred.mathworks.com>... > Hi All > I am trying to use function eval to a structure variable. For sake of simplicity, first create a structure sv as > > sv.f1=5; > sv.f2=6; > > The question is I can't access the fields of sv using > > eval('sv').f1 > > Any suggestion? Thanks in advance. Why do you think you need to use eval? You should try to avoid using eval if at all possible. See the answer to Q4.6 of the MATLAB FAQ at: http://matlabwiki.mathworks.com/MATLAB_FAQ It may be of some use to you.
From: Oleg Komarov on 13 Jul 2010 17:04 "Bo " <b.wang(a)warwick.ac.uk> wrote in message <i1ihrh$e44$1(a)fred.mathworks.com>... > Hi All > I am trying to use function eval to a structure variable. For sake of simplicity, first create a structure sv as > > sv.f1=5; > sv.f2=6; > > The question is I can't access the fields of sv using > > eval('sv').f1 > > Any suggestion? Thanks in advance. sv.('f1') is equivalent to sv.f1 so you can do something like: for n = 1:10 sv.( ['f' num2str(n)] ) end Oleg
|
Pages: 1 Prev: plot figure won't appear Next: correlation matrix |