reading data from a file which include symbols.

I need to read the first column of the file attached and the last 3 digits of each line as a column. Appreciate any help.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Mayo de 2015
t = regexp(fileread('Dst.txt'), '(\r)?\n', 'split');
firstcol = regexp(t, '^\S+', 'match');
last3 = regexp(t, '...$', 'match');
first_last = [firstcol(:), last3(:)];
first_last{1,1}, first_last{1,2} is the pair for the first line

1 comentario

anton fernando
anton fernando el 28 de Mayo de 2015
Thank you very much. It works. but I do not understand what the code does. Can you put comments on it so that I can understand it. Appreciate it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Mayo de 2015

Comentada:

el 28 de Mayo de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by