I have a text file which is an output from the command line of a diff program. I now read the file using
fileID = fopen('runInfo.out','r');
file_dump = textscan(fileID, '%s', 'Delimiter', '\n');
% Find postion of Min Cp to mark field on interest
Row = find(~cellfun('isempty',strfind(file_dump{1}, 'Minimum Viscous Cp')));
fclose(fileID);
I now have the row from which I need to extract data. The format of the file from this location looks something like
.OPERv c>
u/Uinf = 1.0050 v/Uinf = -0.0029
q/Uinf = 1.0050 Cp = -0.0100
.OPERv c>
u/Uinf = 1.0088 v/Uinf = -0.0075
q/Uinf = 1.0088 Cp = -0.0177
.OPERv c>
u/Uinf = 1.0156 v/Uinf = -0.0281
q/Uinf = 1.0160 Cp = -0.0323
Since I already have this data in my cellArray from textscan
,
What I could think of was (pretty non robust)
u_line = vertcat(file_dump{1,1}...
{find(~cellfun('isempty',strfind(file_dump{1}, 'u/Uinf'))),1})
v = str2num(u_line(:,end-5:end));
and then somehow extract the numbers from these returned cells? In the end, I need the four values of u/Uinf, v/Uinf, q/Uinf and Cp. Is there a simpler option that I am missing?