フィルターのクリア

Extracting specific data from a cell array

1 回表示 (過去 30 日間)
fadzhi
fadzhi 2021 年 2 月 1 日
編集済み: Stephen23 2021 年 2 月 2 日
Dear all,
I am using following code to read data from multiple text files. So far is okay. Now i wanted to create a matrix that takes entries from the 9th and 11th colum of each cell array A (with changing length due to new text files) and places them after one another. Many thanks for your suggestion and ideas.(Example file is attached)
D = 'T:\New\files';
S = dir(fullfile(D, '*.txt'));
N = length(S);
A = cell(N,1);
fmt = '%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f';
% fmt=repmat('%f',1,2);
for k = 1:N
fid = fopen(fullfile(D,S(k).name), 'r');
A(k)= textscan(fid, fmt, 'Delimiter', '\t', ...
'headerlines', 33, ...
'CollectOutput', 1);
fid=fclose(fid);
end

採用された回答

Stephen23
Stephen23 2021 年 2 月 1 日
編集済み: Stephen23 2021 年 2 月 2 日
After the loop:
M = vertcat(A{:});
out = M(:,[9,11])

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by