问题说明
为了批量读取144个txt文件中的数据进行matlab代码编程。这144个文件为8*18个,名称共有8中,每种对应18个文件-1,-2,-3…
step1、批量生成txt文件路径
step2、进行文件的读取,textread()函数
matlab代码以及注释
result3=zeros(144,4);
road=cd;%文件夹名称% road='C:\Users\liyuanfu\Desktop\second run\RESULT\';
name_str={'whole2-','whole2R-','T2.5-','T2.5R-','T5-','T5R-','T10-','T10R-'};%文件开头名称
% char(name_str(7));
% s1='whole2-';
% s2='whole2R-';
% s3='T2.5-';
% s4='T2.5R-';
% s5='T5-';
% s6='T5R-';
% s7='T10-';
% s8='T10R-';
txt='.txt';
%str='''';%单引号的字符串
for i=1:8
for j=1:18
n=strcat(char(name_str(i)),num2str(j),txt);%char(name_str(i)),num2str(j)将数字转换为字符串的形式
name=fullfile(road,n);%生成路径名称
result3(j+18*(i-1),:)=textread(name);
end
end