Ältere Kommentare anzeigen
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 Kommentare
bym
am 23 Jun. 2011
I suppose changing the Labview vi to save the files in a more user friendly way is not an option?
Walter Roberson
am 23 Jun. 2011
Please do not create duplicate questions.
Walter Roberson
am 23 Jun. 2011
duplicate is at http://www.mathworks.com/matlabcentral/answers/9897-filename-parsing
Antworten (1)
Jan
am 23 Jun. 2011
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);
Kategorien
Mehr zu LabVIEW finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!