MATLAB: Grabbing values from .txt to create stacked bar graph

clinical reportfgetlfileidstacked bar graph

report_data.txt contains
I want to grab ( fgetl(fileID) ?) healthy_exposed, pus, and necrotic and create a stacked bar graph.
figure;
bar(1:3, cat(1,[healthy_exposed, pus, necrotic]), 0.5, 'stack');
% Adjust the axis limits
axis([0 4 0 100]);
% Add title and axis labels
title('Chronology of Wound Specifications');
xlabel('Date of Visit');
ylabel('Percentage');
% Add a legend
legend('Healthy', 'Infection', 'Necrotic');
But I'm not 'grabbing them' properly. How do I do that?

Best Answer

your fgetl(fileID) will get each line of data but you'll have to extract the data from the line. you can use the strfind(line,'=') which will give you your data for each line:
currentline = fgetl(fileID);
equalpos = strfind(currentline,'=');
linesdata = str2num(currentline(equalpos+1:end));
if your reports are consistent you can read in each line and associate the the data to the correct variable. given the specific line you could even use the eval([fgetl(fileID) ';']) such that it'll evaluate the line >>healthy_exposed = 75 ;