MATLAB: How to import specific data from .f06 file in MATLAB

.f06tomatlab

I want to write a code which imports specific data from the .f06 file to plot graphs.

Best Answer

S = fileread('data.txt');
SS = regexprep(S, '^.*POINT ID.*?\n', '');
datacell = textscan(SS, '%f %s %f %f %*f %*f %*f %*f');
%the line after the last row happens to start with a number, and
%the %s is happy to eat the field after that, but then the %f for the
%third column fails to match. So the first two cells might be one
%entry longer than the third and fourth. Trim away excess
minlen = min(cellfun(@length, datacell));
datacell = cellfun(@(V) V(1:minlen, :), datacell, 'uniform', 0);
%everything is same length now
col1 = datacell{1}; %numeric


col2 = datacell{2}; %cell array of character vectors, probably single characters
col3 = datacell{3}; %numeric
col4 = datacell{4}; %numeric