views:

38

answers:

2

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?

A: 

I just want to clarify that I am using Matlab.

Matlabo09
You can edit your question if you have additional information. I suggest you delete this answer.
Otto Allmendinger
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

related questions