MATLAB: Read numbers and characters from text file into a single array

data importMATLABtext file

I have a .txt file with numbers and characters separated by spaces. The numbers and characters always appear in the same columns. The file looks something like:
0 0 C 21.5 TRC 0 5896.201 5
0 3 B 5.2 BTR 1 482.107 0
0 0 C 19.1 TRC 0 3148.151 0
How would you import the data into a single array? If it is not possible to read both numbers and characters into a single array, then how would you extract just the numbers from the file?
Thank you!

Best Answer

Simpler:
format longg
T=readtable('sample.txt'); % your text file , attached sample.txt with this answer
T=table2cell(T);
a=cell2mat(T(cellfun(@isnumeric,T)));
Result=reshape(a,size(T,1),[])
Gives:
Result =
0 0 21.5 0 5896.201 5
0 3 5.2 1 482.107 0
0 0 19.1 0 3148.151 0