How to read one number from multiple text files
Mostrar comentarios más antiguos
Hello,
I have been struggeling with finding a way to read 1000 text files into matlab. The text files have letters in them as well, however from every text file I only want one number. I have tried dlmread, that doesnt work. I Have tried fopen, I couldnt figure out how can I specifiy the numer location (which row and couloumn).
I would very much appreciate it if someone knows a way!!
5 comentarios
dpb
el 17 de Mzo. de 2020
Well, in general the simplest way to do such would be to just read the whole file into MATLAB and then do the selection in memory -- most of the time that will also be the fastest rather than doing partial reads inside the file itself.
To answer for a specific file would need to know what the actual file format is...a smallish sample that illustrates is always best.
Maha Almarzooqi
el 17 de Mzo. de 2020
Walter Roberson
el 17 de Mzo. de 2020
Okay, and which one number would you want out of that?
Maha Almarzooqi
el 18 de Mzo. de 2020
dpb
el 18 de Mzo. de 2020
That's a trivial file format to read presuming that is the beginning of the file...
data=readmatrix('Yourfilename.txt','NumHeaderLines',1,'Range','E6');
the overhead of the specific element read may/may not be significant; the previous suggestion would have just been
data=readmatrix('Yourfilename.txt','NumHeaderLines',1); % read full data array
data=data(5,6); % keep the wanted data
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Text Analytics Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
