How to read Value from .txt
1 次查看(过去 30 天)
显示 更早的评论
Here i am attaching screenshot of my file which is in .txt format, i have to read the three values (Marked in the screenshot) from the file. Could you please help me in this ??
6 个评论
Walter Roberson
2020-6-15
编辑:Walter Roberson
2020-6-15
fopen(), textscan() with headerlines 2, format '%*s%f%f%f', 'collectoutput', true, and count 1 (the count goes immediately after the format and before any other options.) cell2mat() the result of textscan() to get the numeric data. fclose()
采纳的回答
Walter Roberson
2020-6-15
filename = 'File.txt';
fid = fopen(filename, 'rt');
GAL = cell2mat(textscan(fid, '%*s%f%f%f', 1, 'headerlines', 2, 'collectoutput', true));
fclose(fid);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!