How to read .txt file in matlab (comma delimiter)
38 ビュー (過去 30 日間)
古いコメントを表示
Hi guys, I would like to read all the data (including the header) from this .txt file, I could only read the numbers using dlmread, please assist me on this:
Adjusted depth,temp,trans
1,22.5,122.3
3,22.6,111.5
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 11 月 5 日
fid = fopen('YourFile.txt', 'rt');
tline = fgetl(fid);
headers = strsplit(tline, ','); %a cell array of strings
datacell = textscan(fid, '%f%f%f', 'Delimiter',',', 'CollectOutput', 1);
fclose(fid);
datavalues = datacell{1}; %as a numeric array
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!