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.

 채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 27일

0 개 추천

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

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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2015년 5월 27일

댓글:

2015년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by