From: jenya polyakova on
numreal = 100;
for iz = 1:numreal
str1 = cat(2,'gsod_temp',num2str(iz));
str2 = cat(2,'gsod_new',num2str(iz));
eval([str1 '(ka)=str2{ind_tm(index_r1(i))}(index_r2)']);
end
it gives me an error:
Cell contents reference from a non-cell array object.
When I have single iteration (i.e. numreal =1) the following line works just find:
gsod_temp1(ka) = gsod_new1{ind_tm(index_r1(i))}(index_r2);
Any suggestions?
Thanks!!!!
From: Steven Lord on

"jenya polyakova" <jenya56(a)yahoo.com> wrote in message
news:i0cbh5$f8h$1(a)fred.mathworks.com...
> numreal = 100;
> for iz = 1:numreal
> str1 = cat(2,'gsod_temp',num2str(iz));
> str2 = cat(2,'gsod_new',num2str(iz));
> eval([str1 '(ka)=str2{ind_tm(index_r1(i))}(index_r2)']);

DO NOT DO THIS. See Q4.6 in the newsgroup FAQ for an explanation why this
is a Bad Idea and alternatives you should use instead.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: us on
"jenya polyakova" <jenya56(a)yahoo.com> wrote in message <i0cbh5$f8h$1(a)fred.mathworks.com>...
> numreal = 100;
> for iz = 1:numreal
> str1 = cat(2,'gsod_temp',num2str(iz));
> str2 = cat(2,'gsod_new',num2str(iz));
> eval([str1 '(ka)=str2{ind_tm(index_r1(i))}(index_r2)']);
> end
> it gives me an error:
> Cell contents reference from a non-cell array object.
> When I have single iteration (i.e. numreal =1) the following line works just find:
> gsod_temp1(ka) = gsod_new1{ind_tm(index_r1(i))}(index_r2);
> Any suggestions?
> Thanks!!!!

a hint:
- do NOT do this...

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

us