Пакетный процесс:
% Slurp in all lines.
f = fopen('foo.txt');
c = textscan(f,'%s','Delimiter','\n');
lines = c{1};
fclose(f);
% Remove headers.
lines(1:14:end) = [];
lines(1:13:end) = [];
lines(1:12:end) = [];
lines(1:11:end) = [];
% Extract data.
output = zeros(numel(lines),2);
for i = 1:numel(lines)
x = lines{i};
output(i,1) = datenum(x(1:19),'mm/dd/yyyy HH:MM:SS') + ...
str2double(x(20:26));
output(i,2) = str2double(x(28:end));
end
Или как конечный автомат:
f = fopen('foo.txt');
output = [];
while true
for i = 1:4
x = fgetl(f);
if x == -1
break
end
end
for i = 1:10
x = fgetl(f);
if x == -1
break
end
time = datenum(x(1:19),'mm/dd/yyyy HH:MM:SS') + ...
str2double(x(20:26));
val = str2double(x(28:end));
output(end+1,1:2) = [time,val];
end
if x == -1
break
end
end
fclose(f);