I converted the names of 12000 different .TXT files into a sequence of numbers from 1 to 12000. Using Matlab, how can I create a list or a vector with the original file name beside the corresponding number?
views:
38answers:
2You can edit your question if you have additional information. I suggest you delete this answer.
Otto Allmendinger
2010-02-22 15:50:15
A:
You may want to create a cell array, since they can store both numbers and text at the same time. How you create the array depends on how you have stored the file names.
namesAndNumbers = cell(12000,2); % create cell array
%# fill in names
%# assuming the 12000 file names are in a structure you got via dir
[namesAndNumbers{:,1}] = deal(nameStruct(idxOfFirstFile:idxOfLastFile).name);
%# assuming the 12000 file names are in a cell array already
namesAndNumbers(:,1) = nameCell;
%# and for the numbers
%# assuming that the numbers are generated by a function name2number
namesAndNumbers(:,2) = cellfun(@(n)(name2number(n)),namesAndNumbers(:,1));
Jonas
2010-02-22 16:13:52