Plotting Cell Array in APP Designer

4 ビュー (過去 30 日間)
Marcin Laszkiewicz
Marcin Laszkiewicz 2020 年 10 月 15 日
コメント済み: Marcin Laszkiewicz 2020 年 10 月 16 日
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 Center および File ExchangeBar Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by