MATLAB: Extract data from a text data.

text file

Hi all!
i have a text file. it is constructed like this:
input start1
a:12 b:1.5 c:1.75 d:0.25
a:52 b:3.5 c:2.75 d:0.75
a:12 b:1.5 c:1.75 d:0.25
...
...
...
a:12 b:1.5 c:1.75 d:0.25
output end1
input start2
a:12 b:1.5 c:1.75 d:0.25
a:52 b:3.5 c:2.75 d:0.75
a:12 b:1.5 c:1.75 d:0.25
...
...
...
a:12 b:0 c:1.752 d:0.225
output end2
input start3
..
...
...
...
How could read this text file? imean i want just th parameter a b c d .
thank you

Best Answer

fid=fopen('file.txt','r');
text=textscan(fid,'a:%f b:%f c:%f d:%f \n');
fclose(fid);
text will be a 1*4 cell array, where text{1,1} is the vector of all your a, where text{1,2} is the vector of all your b...