0

我有 48 个 1000x28 数据文件(没有标题、字符串或特殊字符),我想分 4 批导入,每批 12 个。在第一批中,这些文件具有名称:

spread_YAB_4ACH_caretype_??_model_1 where ??=1:6

第二批

spread_YAB_4ACH_caretype_??_MC_model_1??=1:6 不知道在哪里放置通配符 *

D = dir('spread_YAB_4ACH_caretype_*_model_1.txt');
 dummy=zeros(1000,length(D));

for k=1:length(D)
   file = num2str(D(k).name);
 fid=fopen(file);
   myCell = textscan (fid, '%f');
   dummydummy=reshape(cell2mat(myCell(:,end)),1000,28); %#cell makes one column vector, why?
   dummy(:,k)=dummydummy(:,end);                        %# Only want last column
 fclose(fid);
end

这个脚本看起来一团糟,你肯定不需要这么多的bumpf来导入一组简单的数据文件。有什么想法吗?

4

1 回答 1

1
d=dir(foldername); %#That is where your files are
for i=3:1:length(d) %#ignore the . and ..
    if strfind(d(i,1).name,'MC_model')
         %#some code to do with the file of the second batch#%
    else
        %some code to do with the file of the first batch#%
    end
end
于 2013-03-07T13:11:56.310 回答