What do I have to add at the beginning of this loop?

别等时光非礼了梦想. 提交于 2019-12-02 08:59:01

You can avoid constructing the filenames by using the DIR command. For instance:

myfiles = dir('*.txt');
for i = 1:length(myfiles)
    nom_fichier = myfiles(i).name;
    ...do processing here...
end

First of all, why would you use strcat here? This is, by itself, a SINGLE string. All concatenation has already been done by the brackets [].

['MyFile\.......' num2str(i) '.TXT']

Next, I'm not certain what is your question here. Is it how to load in the data? If the files are simply delimited numbers, with the same number of them on each line, then load will suffice to load them in, or perhaps you may need textread.

My guess is you do not know how to build the main part of of the file name. You might do it this way:

Names = {'abc' 'cde 'ser' 'wsz' 'aqz' 'iop'};
for i = 1:6
  fn = ['MyFile',filesep,Names{i},'-',num2str(i),'.TXT'];
  data = load(fn);

  % do other stuff ...

end

If you don't want to create a variable with the names by typing them in, then use dir, perhaps like this to create a list of text file names:

Names = dir('MyFile\*.TXT');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!