フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

importing a column of data from a text file

1 回表示 (過去 30 日間)
Siddharth
Siddharth 2013 年 5 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
i need to import a particular column of data from a text file. the columns are differentiated by the size of the numbers. For example :
20 30000
21 40000
24 50000
how can i do so?

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 29 日
編集済み: Azzi Abdelmalek 2013 年 5 月 29 日
Import the data using
data=dlmread('yourfilename.txt')
Then choose the column you want
data(:,2)
% You can get the sizes of numbers in each column
numbers=arrayfun(@(x) numel(num2str(x)),data(1,:))
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 29 日
編集済み: Azzi Abdelmalek 2013 年 5 月 29 日
data=dlmread('yourfilename.txt')
numbers=arrayfun(@(x) numel(num2str(x)),data(1,:))
[idx,idx]=max(numbers)
result=data(:,idx)
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 29 日
or simply
data=dlmread('yourfilename.txt')
[idx,idx]=max(data(1,:))
result=data(:,idx)

Andrei Bobrov
Andrei Bobrov 2013 年 5 月 29 日
編集済み: Andrei Bobrov 2013 年 5 月 29 日
d = dlmread('yourtxtfile.txt');
[k,k] = max(log10(d(1,:)));
out = d(:,k);
or
[k,k] = max(log10(d(:)));
out = d(:,ceil(k/size(d,1)))

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by