Plotting Cell Array in APP Designer

4 次查看(过去 30 天)
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!

回答(1 个)

Kevin Chng
Kevin Chng 2020-10-16
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 个评论
Marcin Laszkiewicz
Marcin Laszkiewicz 2020-10-16
Thanks Kevin. Does the entire thing go directly into the startup function?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by