I read a .txt file into a 1x1 cell array using textscan. How to I extract certain data from that 1x1 cell array?
The .txt file has mixed format data.
The code I have so far:
%% Import Safir output file
FileName="PROOV_6.txt";
tic
%% Read the txt file
FID = fopen(FileName, 'r');
if FID == -1
error('Cannot open file')
end
Data = textscan(FID, '%s', 'delimiter', '\n', 'whitespace', ' ' );
CStr = Data{1};
fclose(FID);
%% Find all row numbers that contain the string
Index = strfind(CStr, 'TOTAL TEMPERATURES');
IndexA = find(not(cellfun('isempty', Index)));
%% Loop through CStr accessing matrices between strings "TOTAL TEMPERATURES"
%% ----------
%% Save the file again
FID = fopen(FileName, 'w');
if FID == -1
error('Cannot open file')
end
fprintf(FID, '%s\n', CStr{:});
fclose(FID);
toc
I will also provide a link to the .txt file: PROOV_6.txt