grabbing values from .txt to create stacked bar graph

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Joseph Cheng
Joseph Cheng il 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 Commento
Golnar
Golnar il 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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by