From: Steven Lord on

"vgsangiuliano Poretti" <vgsangiuliano(a)gmail.com> wrote in message
news:hp6uk8$e2j$1(a)fred.mathworks.com...
> Hi to all,
> Can anyone say me how to use a field of a struct variable as a counter for
> a FOR cicle?
>
> When I use
>
> for x.test=1:1:10 I get
> |
> Error: Unexpected MATLAB operator.
>
> of course using for x=1:1:10 is correct

As us said, you can't do this. The closest approximation you can do is:

for k = 1:10
x.test = k;
% do the rest of the body of the loop
end

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ