Plotting Cell Array in APP Designer
1 次查看(过去 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/382468/image.jpeg)
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!
0 个评论
回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!