MATLAB: Remove the Text from the files

text;textscan

Hi all,
i have a big number of fileswhich contains data with this structure. Is there any easy method to remove the Text and get only the numbers. Thank you!
Text
Text Text Text
5.420 12 0.6555
5.430 0 0.6698
2.440 5 0.6236
7.450 1 0.6324
9.460 15 0.6331
Text
Text Text Text
5.420 127 0.6555
5.430 0 0.6698
2.440 5 0.6236
7.450 1 0.6324
9.460 129 0.6331
Text
.....
...

Best Answer

This is fast and easy using textscan in a loop:
k = 0;
opt = {'MultipleDelimsAsOne',true};
fid = fopen('temp.txt','rt');
tmp = textscan(fid,'%s',1);
while ~isempty(tmp{1}) && k<1000
k = k+1;
C(k,:) = tmp; %#ok<SAGROW>


D(k,:) = textscan(fid,'%s%s%s',1,opt{:}); %#ok<SAGROW>
M(k,:) = textscan(fid,'%f%f%f',opt{:}); %#ok<SAGROW>
%
tmp = textscan(fid,'%s',1);
end
fclose(fid);
It works because textscan will read only as much of the file as its format string matches. Every time it reaches the end of a block of text+numeric data we loop back to start again... until finally textscan does not match anything (i.e. the end of the file), then we stop.
The output cell arrays contain all of the data from the file:
>> C
C =
{1x1 cell}
{1x1 cell}
>> C{1}
ans =
'Text'
>> M
M =
[5x1 double] [5x1 double] [5x1 double]
[5x1 double] [5x1 double] [5x1 double]
>> M{1}
ans =
5.4200
5.4300
2.4400
7.4500
9.4600
Because the original question did not include any sample data-file I created this test file: