I need a function or equivalent code fgetl, but it is very fast.

9 ビュー (過去 30 日間)
Clodoaldo de Souza Faria Júnior
Clodoaldo de Souza Faria Júnior 2021 年 9 月 21 日
回答済み: Steven Lord 2021 年 9 月 21 日
This is slowing down my code, at some point it takes 10 seconds per iteration in this function only.

回答 (1 件)

Steven Lord
Steven Lord 2021 年 9 月 21 日
Are you sure that fgetl is what's taking the time? Or are you trying to read data one line at a time from a file and storing each line in turn in a cell array, and if so is growing the cell array the bottleneck? Can you show a bit of context for your fgetl call?
If you just want to read in data all at once, try fileread. You'd need to split it into its constitutent lines if you wanted to process a line at a time, but at least you'd only perform file I/O once.
t = fileread('bench.dat');
t(1:80)
ans =
'MATLAB(R) Benchmark Data. Copyright 1984-2021 The MathWorks(R), Inc. '

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by