matlab批量读取同一目录下的txt文件

万万没想到这么一个简单问题花费几天时间才搞定,严重怀疑自己的学习能力了。废话少说,我是读取目录:‘E:\轨迹\gesture dataset\自己数据集\data\总’   下的文件。直接来代码:


namelist  = dir('E:\轨迹\gesture dataset\自己数据集\data\总\*.txt');

% 读取后namelist 的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not


l = length(namelist);

 for i=1:l
        file_name{i}=namelist(i).name;
        x= load(file_name{i});
 end

这里得到的x为最后的txt文档内容,至于分别加载到不同的矩阵,正在研究中。。

你可能感兴趣的:(matlab,MATLAB)