Importing text like this can be a real pain; usually, this is a good test of your knowledge of string manipulation :)
I believe the following commands will do nicely:
% Read in entire file as string
fid = fopen('yourFile.txt');
C = textscan(fid, '%s', 'delimiter', '');
fclose(fid);
C = C{1};
% Remove first part (from column 39 onwards in your example;
% adjust to match your actual data)
C = cellfun(@(x)x(39:end), C, 'UniformOutput',false);
% Remove unwanted junk
% NOTE: this removes all occurrences of 'rpm', 'deg',
% 's', and the trailing '0.0%'
C = regexprep(C, {'deg' 'rpm' 's' '([0-9]+\.[0-9]+%)$'}, '');
% Tokenize string and convert to double
C = cellfun(@(x)textscan(x, '%f'), C);
I tested this with yourFile.txt
:
Ex1: 2012-11-01 00:00:00.00 XX YY 00.000s 000.00deg 0.00rpm 0.00rpm
Ex2: 2012-11-01 00:00:00.00 XX YY 00.000s 000.00deg 0.00rpm
Ex3: 2012-11-01 00:00:00.00 XX YY 00.000s 0.00deg 0.00rpm 0.00rpm 0.0deg
Ex3: 2012-11-01 00:00:00.00 XX YY 00.000s 0.00deg 0.00rpm 0.00rpm 0.0deg 0.0%
Ex4: 2012-11-01 00:00:00.00 XX YY 00.000s 0.00rpm
Ex4: 2012-11-01 00:00:00.00 XX YY 00.000s 0.00rpm
The final contents of C
with the commands above is
>> C{:}
ans =
0
0
0
0
ans =
0
0
0
ans =
0
0
0
0
0
ans =
0
0
0
0
0
ans =
0
0
ans =
0
0