MATLAB: Reading data from a file which include symbols.

read a complex txt file

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.

Best Answer

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