Plotting Cell Array in APP Designer

2 views (last 30 days)
Marcin Laszkiewicz
Marcin Laszkiewicz on 15 Oct 2020
Hey so I'm working on a GUI that will display Covid cases, deaths, or both in the world and in individual countries depending on the users inputs. I'm trying to get the GUI to plot the data from a single country for now and I'm having a lot of trouble with it. As you can see below, the cell array I'm working with contains dates in the first row, country's and regions in the first two columns, and the remaining cells contains two values, one for cases and one for the deaths. I'm not sure how to separate those values when I go to plot.
I think the plot command in the startup function will looke something like this for Angola:
cellfun(plot(app.UIAxes,covid_data{1,(3:end)},covid_data{6,(3:end)}), covid_data);
But this doesn't work probably because the Y values being plotted contain 2 numbers in each cell. Any ideas on how to move forward?
Thanks!

Answers (1)

Kevin Chng
Kevin Chng on 16 Oct 2020
try :
After running the code below, you shuld have 2 nice table to plot your figure
date = covid_data(1,3:end)';
covid_data = covid_data(2:end,3:end)';
covid_data.Properties.VariableNames = covid_data{2:end,1};
%new case/death case(first value)
covid_data_new=table;
for i=1:1:height(covid_data)
for k=1:1:width(covid_data)
covid_data_new{i,k} = covid_data{i,k}{1}(1)
end
end
covid_data_new.Properties.VariableNames=covid_data.Properties.VariableNames
%new case/death case(second value)
covid_data_death=table;
for i=1:1:height(covid_data)
for k=1:1:width(covid_data)
covid_data_death{i,k} = covid_data{i,k}{1}(2)
end
end
covid_data_death.Properties.VariableNames=covid_data.Properties.VariableNames
  1 Comment
Marcin Laszkiewicz
Marcin Laszkiewicz on 16 Oct 2020
Thanks Kevin. Does the entire thing go directly into the startup function?

Sign in to comment.

Categories

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

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!