12000 の異なる .TXT ファイルの名前を 1 から 12000 までの一連の番号に変換しました。Matlab を使用して、対応する番号の横に元のファイル名を含むリストまたはベクトルを作成するにはどうすればよいですか?
1 に答える
1
数値とテキストの両方を同時に格納できるため、cell 配列を作成することをお勧めします。配列の作成方法は、ファイル名の保存方法によって異なります。
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));
于 2010-02-22T16:13:52.683 に答える