MATLAB: How to define a row delimiter

import text file delimiter measurement

I want to import a measurement sequence from a text file to a numeric matrix. The file looks like this: 0.458(tab)0.868(tab)0.753(tab)0.748(tab)0.858(tab);0.468(tab)0.852(tab)0.159(tab)0.846(tab)0.748(tab)
Is there an efficient way to import this example to a 2-by-5 Matrix? I want Matlab to make a new row after a semicolon.

Best Answer

Use textscan and set the Delimiter and EndOfLine options, e.g.:
opt = {'Delimiter','\t', 'EndOfLine',';'};
fmt = repmat('%f',1,5);
[fid,msg] = fopen('temp5.txt','rt');
assert(fid>=3,msg)
C = textscan(fid,fmt,opt{:});
fclose(fid);
M = [C{:}]
which imports this matrix using the file attached to this answer:
M =
0.45800 0.86800 0.75300 0.74800 0.85800
0.46800 0.85200 0.15900 0.84600 0.74800