フィルターのクリア

Extract subcell array in a single cell array

4 ビュー (過去 30 日間)
Maurizio
Maurizio 2011 年 12 月 21 日
Hi I have 25000 file txt and I wrote the below code to read all the txt extract all the value and than I will use for some calculation.
The problem is that at the moment I have valC that is composed by 25000cell and each cell is composed by <14x1>cell. I would like to remove one level or extract the 14value of each cell for 25000times in a single 25000x14cell. Is it possible?
fileList = dir('*.txt');
nameFile = cell(1, numel(fileList)); % Pre-allocate!
for i = 1:numel(fileList)
NAME = fileList(i).name; % [EDITED]
nameFile{i} = NAME;
fid = fopen(NAME);
valC(i) = textscan(fid, '%s', 'delimiter', ',');
val = valC;
fclose(fid);
end

採用された回答

Jan
Jan 2011 年 12 月 21 日
fileList = dir('*.txt');
nameFile = {fileList.name}; % Pre-allocate!
data = cell(numel(fileList), 14);
for i = 1:numel(fileList)
fid = fopen(nameFile{i});
valC = textscan(fid, '%s', 'delimiter', ',');
data(i, :) = transpose(valC{1});
fclose(fid);
end
I cannot test this, because I do not have your data files. So please debug this and post, if there are problems.
  2 件のコメント
Matt Tearle
Matt Tearle 2011 年 12 月 21 日
Beat me to it. Yes, that.
Maurizio
Maurizio 2011 年 12 月 21 日
FANTASTIC. PERFECT

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by