Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
importing a column of data from a text file
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
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
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
2013년 5월 29일
or simply
data=dlmread('yourfilename.txt')
[idx,idx]=max(data(1,:))
result=data(:,idx)
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)))
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!