read only the numerical value of a file
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a file which is attached. I just want to read the number in it and store it in a variable. Thanks for your help.
0 个评论
采纳的回答
Star Strider
2018-1-15
This works:
filename = 'out_log_test-weak.txt';
fidi = fopen(filename,'rt');
D = textscan(fidi, '%*s%f%%', 'HeaderLines',1);
number = [D{:}]
number =
90.0800
11 个评论
Star Strider
2018-1-15
Thanks! This information could help if others have the same problem.
Restarting MATLAB might not have been necessary, though. Running:
fclose('all');
from your Command Window could have worked.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!