grabbing values from .txt to create stacked bar graph

1 vue (au cours des 30 derniers jours)
Golnar
Golnar le 23 Mar 2014
Commenté : Golnar le 26 Mar 2014
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?

Réponse acceptée

Joseph Cheng
Joseph Cheng le 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 commentaire
Golnar
Golnar le 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by