Loop for reading and extracting data from a single line of multiple text files.
I have the following code that I would like to put into a loop to read multiple text files.
txt = fileread(‘Test01.txt’);
temppos = strfind(txt,’Ground Temperature:’);
endpos = strfind(txt, ‘°C’);
for k = 1:numel(temppos)
section{k,:} = txt(temppos(k):endpos(k));
end
for k = 1:numel(section)
temp(k,:) = sscanf(section{k}, ‘Ground Temperature: %f’);
end
Results = table(temp, ‘VariableNames’,{‘Temp’});I have the following code that I would like to put into a loop to read multiple text files.
txt = fileread(‘Test01.txt’);
temppos = strfind(txt,’Ground Temperature:’);
endpos = strfind(txt, ‘°C’);
for k = 1:numel(temppos)
section{k,:} = txt(temppos(k):endpos(k));
end
for k = 1:numel(section)
temp(k,:) = sscanf(section{k}, ‘Ground Temperature: %f’);
end
Results = table(temp, ‘VariableNames’,{‘Temp’}); I have the following code that I would like to put into a loop to read multiple text files.
txt = fileread(‘Test01.txt’);
temppos = strfind(txt,’Ground Temperature:’);
endpos = strfind(txt, ‘°C’);
for k = 1:numel(temppos)
section{k,:} = txt(temppos(k):endpos(k));
end
for k = 1:numel(section)
temp(k,:) = sscanf(section{k}, ‘Ground Temperature: %f’);
end
Results = table(temp, ‘VariableNames’,{‘Temp’}); loop, sscanf, fid MATLAB Answers — New Questions