Mostrar comentarios más antiguos
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 comentarios
bym
el 23 de Jun. de 2011
I suppose changing the Labview vi to save the files in a more user friendly way is not an option?
Walter Roberson
el 23 de Jun. de 2011
Please do not create duplicate questions.
Walter Roberson
el 23 de Jun. de 2011
duplicate is at http://www.mathworks.com/matlabcentral/answers/9897-filename-parsing
Respuestas (1)
Jan
el 23 de Jun. de 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);
Categorías
Más información sobre LabVIEW en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!