MATLAB: What’s the best way to read in a text file

read datatext file

I would like to read in a text file that has different delimiters and get a separate variable for each column of data. Here is an example of the format.
30 -4.05 03.11.2010 12:05:21
from the above line, i would like to get:
a = 30,
b = -4.05,
c = 3,
d = 11,
e = 2010,
f = 12,
g = 05,
h = 21
I would also like to be able to choose the file that I read in using uigetfile…
Any advice to get me going would be much appreciated!

Best Answer

Edit
fid=fopen('fic.txt');
v=textscan(fid,'%s','delimiter',{',',':',' '},'MultipleDelimsAsOne', 1);
fclose(fid);
a=reshape(v{:},6,[]);
b=cellfun(@(x) regexp(x,'\.','split'),a(3,:),'un',0);
out=cell(size(a)+[2 0]);
out([1:2 6:8],:)=a([1:2 4:6],:);
out(3:5,:)= reshape([b{:}],3,[])