best way in terms of performance to read a text file
2 次查看(过去 30 天)
显示 更早的评论
I have to read values from text file that have this body:
1 2 3 4 5 6 7 8 9 10
after having read every of those value I would copy them in a vector. which is the best way in terms of speed and performance?
0 个评论
采纳的回答
Sven
2012-9-28
编辑:Sven
2012-9-28
If your text file has exactly what you've got there (numbers separated by spaces):
---== contents of test.txt ==---
1 2 3 4 5 6 7 8 9 10
--------------------------------
Then just use importdata
A = importdata(filename)
A =
1 2 3 4 5 6 7 8 9 10
Quick, simple. MATLAB will be pretty optimised to read this kind of file. Is that what you were looking for?
0 个评论
更多回答(1 个)
另请参阅
类别
在 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!