Matlab 如何只导入一些数据文件而忽略其他数据文件?
我有48个1000x28数据文件(没有标题、字符串或特殊字符),我想分4批12个导入。 在第一批中,文件的名称为: spread\u YAB\u 4ACH\u caretype\u???\ u model\u 1Matlab 如何只导入一些数据文件而忽略其他数据文件?,matlab,import,Matlab,Import,我有48个1000x28数据文件(没有标题、字符串或特殊字符),我想分4批12个导入。 在第一批中,文件的名称为: spread\u YAB\u 4ACH\u caretype\u???\ u model\u 1其中???=1:6 第二批 排列每种类型的MCU模型1其中再次??=1:6 我不知道把通配符放在哪里* D = dir('spread_YAB_4ACH_caretype_*_model_1.txt'); dummy=zeros(1000,length(D)); for k=1:le
其中???=1:6
第二批
排列每种类型的MCU模型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。有什么想法吗?导入是什么意思?从48.txt文件的结束列中读入1000个数据点,并将它们连续放置到虚拟数组中,以便进行进一步的计算,从而对通配符位进行排序。但是如何将列顺序插入到伪数组中呢?即第1:6列中的所有MC_模型列和第7:12列中的所有非MC_模型列?啊,有一件事,我可以在strfind中使用逻辑运算符吗?ie
strfind(d(i,1).name,'MC_model'~&'4ACH')
?strfind用于在另一个字符串中查找一个字符串,您可以使用它两倍于(strfind(d(i,1).name,'MC_model')&(strfind(第二个条件))完美!非常感谢!如果找不到任何内容,strfind将返回[],因此~在这里不起作用。也许可以尝试strfind(d(i,1).name,'model_1')&isempty(strfind(d.name,'(i,1).名称,'MC_model'))
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