对变量名构造循环。

19 views (last 30 days)
salumie
salumie on 16 May 2023
Answered: gennepa on 16 May 2023
你好,我有一个for循环,想让循环的内容加入到变量名中,请问怎么实现?
比如
for i=1:3
%name=['DOY_',num2str(utc,'%02d')]; name=intersect(x_real1,x_real);
save('out.mat','name’);
end
怎么让这里的name变成 DOY_01 DOY_02 DOY_03? 谢谢

Accepted Answer

gennepa
gennepa on 16 May 2023
eval([name,'=[]']) 就可以构造新的空变量 DOY_03 eval 就是把字符串变成命令执行的

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!