Help parsing
이전 댓글 표시
I am trying to work with a huge collection of files I saved from LabView. They are all saved wit hthe same filename format of: Sample_value1_value2_value3_value4
They are all binary files that I use fopen/fread to use. There is no clear extention either as the last value is a decimal and it is saved awkwardly through the Labview. The values are non-sequential as they come from various device readouts.
Is there a way to write a function that can separate the filenames so I can just call on the values I want? Or a simple way to parse out the the names so I can use one of the values to reference the whole string?
댓글 수: 3
bym
2011년 6월 23일
I suppose changing the Labview vi to save the files in a more user friendly way is not an option?
Walter Roberson
2011년 6월 23일
Please do not create duplicate questions.
Walter Roberson
2011년 6월 23일
duplicate is at http://www.mathworks.com/matlabcentral/answers/9897-filename-parsing
답변 (1개)
Jan
2011년 6월 23일
D = dir(fullfile('C:\Temp\', 'Sample_*'));
Name = {D.name};
nFile = numel(Name);
index = zeros(4, nFile);
for iFile = 1:nFile
index(:, iFile) = sscanf(Name{iFile}, 'Sample_%d_%d_%d_%d');
end
Now you can get the files which have a specific index in a specific position:
pos = 3;
value = 7;
list = Name(index(pos, :) == value);
카테고리
도움말 센터 및 File Exchange에서 LabVIEW에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!