Importing ascii file in matlab with tab as delimiter
조회 수: 11 (최근 30일)
이전 댓글 표시
I need to import the ascii file from matlab script with tab as delimiter and the variables names should be from row 3 and
the data to be imported from A6 to D1000 . Can anyone please help me on this
댓글 수: 3
Mohammad Sami
2020년 11월 30일
You should try readtable function. if you need to customise use the function delimitedTextImportOptions and pass in the options into readtable function.
채택된 답변
Mohammad Sami
2020년 11월 30일
You can try the following.
if true
fname = 'pathtofile.txt';
opts = delimitedTextImportOptions('VariableNamesLine',3,'DataLines',6,'Delimiter','\t');
out = readtable(fname,opts);
end
댓글 수: 0
추가 답변 (1개)
Ameer Hamza
2020년 11월 30일
On R2020b, you can simply use readtable() on the file itself
T = readtable('data.txt')
'data.txt' is attached.
>> T.time
ans =
1
1
1
1
1
1
>> T.A
ans =
1
1
1
1
1
1
>> T.B
ans =
0
0
0
0
0
0
>> T.C
ans =
1
1
1
1
1
1
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!