在此循环开始时我必须添加什么? [英] What do I have to add at the beginning of this loop?

查看:79
本文介绍了在此循环开始时我必须添加什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用for循环读取以下文件:(循环可以忽略文件名中的字符吗?)

how I can read the following files using the for loop: (can the loop ignore the characters in filenames?)

abc-1.TXT
cde-2.TXT
ser-3.TXT
wsz-4.TXT
aqz-5.TXT
iop-6.TXT

abc-1.TXT
cde-2.TXT
ser-3.TXT
wsz-4.TXT
aqz-5.TXT
iop-6.TXT

在此循环开始时我必须添加什么?

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

for i = 1:1:6  
    nom_fichier = strcat(['MyFile\.......' num2str(i) '.TXT']);

推荐答案

您可以避免使用

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

这篇关于在此循环开始时我必须添加什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆