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 CenterFile Exchange에서 Bar Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by