正确排序数据结构中的文件名

时间:2018-07-27 18:53:08

标签: matlab

我有大量的数字文本文件,其名称模式为“ year-month-day-weekday_number.txt”

根据我的分析,年月日和工作日是相同的,但是-数字在我的数据结构中排列不正确,并且看起来像这样(如下),即使数字是连续的(从1到2496,依此类推)< / p>

enter image description here

我的代码如下

%Select folder from which to read the files 
folderName = uigetdir('W:\AOT\matlabdata\');
s=folderName
out=regexp(s,'\','split')
exp = char(out(end))
%Build the string to point to csv files inside of the folder
filePattern = fullfile(folderName, '*.txt');
%load in all the experiments at once..for now just do one at a time
txtFiles = dir(filePattern);

for k = 1:length(txtFiles);
%Points to file were loading in
fileName = fullfile(folderName, txtFiles(k).name);
%temporarily load in text file into a matrix
values = load(fileName);
data.(exp)(k).name = txtFiles(k).name
data.(exp)(k).intensities = values(:,2)
data.(exp)(k).wavelength = values(:,1)
end

我是Matlab的新手,所以我很抱歉,这是一个简单的解决方法……到目前为止,对谷歌搜索没有帮助。

0 个答案:

没有答案