grabbing values from .txt to create stacked bar graph

1 view (last 30 days)
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?

Accepted Answer

Joseph Cheng
Joseph Cheng on 23 Mar 2014
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 ;
  1 Comment
Golnar
Golnar on 26 Mar 2014
Joseph, this is how I grab my values
fileID = fopen('report_data.txt','r');
patientName=fgetl(fileID);
dateOfBirth=fgetl(fileID);
notes=fgetl(fileID);
healthy_exposed = fgetl(fileID);
pus = fgetl(fileID);
necrotic = fgetl(fileID);
ulcer_stage = fgetl(fileID);
area = fgetl(fileID);
volume = fgetl(fileID);
fclose(fileID);
how do I grab them for the stacked bar graph?

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!