Load file and remove string characters.
25 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
apex116
el 28 de Nov. de 2017
Comentada: apex116
el 28 de Nov. de 2017
Hello,
I would like to extract all the numeric data out of a mixed file where the total line length needs to be determined. I have put a screenshot of the first 5 lines of the file.

In the file, I wish to extract the 13 numeric values and ignore the '#' at the end. I have tried to do this below:
fid = fopen('Boundary.cli');
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d',1);
fclose(fid);
This produces the following 1x13 cell:

The issue is that i would like to the read the whole of the file and then convert the cell to a double array of n x 13. Where n is the number of lines of the file.
I would greatly appreciate any help from anyone who knows how to solve this issue.
0 comentarios
Respuesta aceptada
Jan
el 28 de Nov. de 2017
Editada: Jan
el 28 de Nov. de 2017
What about:
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d %s');
Then remove the last column in FC. Or:
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d %[^\n]');
2 comentarios
Stephen23
el 28 de Nov. de 2017
@apex116: read the textscan documentation and use the CollectOutput option.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Export en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!