MATLAB: How to make variables from single lines of a text file

single linetext filevariables

Here are the first several lines (double spaced because of weird question-writing format. Lines 6 and 11 are blank):
Contamination Event: 1046732
Site Location: B (Temporary
Date: 04/11/2014
Distance from initial spill (km): 12
Average River Velocity (km/s): 8
The following data gives the measured
concentration of a contaminant identifed
as C-ASD following a truck accident over
the blah blah River.
time(hrs) Concentration(ppm)
0.000000000000000 0.077557627513634
Under this all, there is just more data, which I've already read into the file and made into variables. How do I turn the 12 and 8 into variables?

Best Answer

fid = fopen('myfile.txt') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
%%Get distance
idx = strfind(S, 'Distance');
idx = find(not(cellfun('isempty',idx)));
%

ACD = S(idx) ;
b=regexp(ACD,'\d+(\.)?(\d+)?','match') ;
Distance=str2double([b{:}])
%%Get Avearge River velocity
idx = strfind(S, 'Velocity');
idx = find(not(cellfun('isempty',idx)));
%
ACD = S(idx) ;
b=regexp(ACD,'\d+(\.)?(\d+)?','match') ;
Velocity=str2double([b{:}])