PLOT ACTION IN TIME LAPS

조회 수: 2 (최근 30일)
Emanuele De Astis
Emanuele De Astis 2021년 2월 16일
댓글: Emanuele De Astis 2021년 2월 19일
hello, i have a dataset with home activities, i need a way to represent the action like in the picture. When the action is running, in this time laps i have 1 as value. when the action isn't running, the time laps represented by 0 as value; but i don't find a solution to rappresent my dataset as in the picture. I've made three different tables where data is organized in different way, tryng to find a solution. Thanks, i'm new in matlab.

채택된 답변

Duncan Po
Duncan Po 2021년 2월 18일
Your data is best represented as a timetable in MATLAB. You can then use stackedplot to generate the visualization.
haa = readtimetable('Home_actionAll.csv');
haa = haa(:,{'Bed_to_Toilet_begin', 'Leave_Home_begin', 'Sleep_begin'}); % the begin variables seem to already capture the information, throw away the rest
haa = varfun(@(x)x>0, haa); % normalize to 0s and 1s
haa.Properties.VariableNames = {'Bed_to_Toilet', 'Leave_Home', 'Sleep'}; % fix the variable names
haa.Properties.VariableContinuity = {'step', 'step', 'step'}; % set continuity such that stairs plots are plotted
sp = stackedplot(haa);
Zooming in shows the stairs better:
  댓글 수: 1
Emanuele De Astis
Emanuele De Astis 2021년 2월 19일
wow, that's fine thanks, in a week i tried a lot of things.
you know a way to eliminated the small steps, like eliminated the action with a duration less than 2 minutes?
i've found this code
MMRT=readtable(Home_ActionAll.csv)
C=(MMRT.Date1(MMRT.Leave_Home==1));
D=(MMRT.Date1(MMRT.Leave_Home==2));
Home=array2table(CD);
Home.Properties.VariableNames([1 2])={'Start' 'End'};
Home.Duration=Home.End-Home.Start;
Home=sortrows(Home);
Home.ID(:)=(2)
Home.Duration1=datenum(Home.Duration);
Home(Home.Duration1<0.001,:)=[];
but with table "Home" I can't get that representation you showed me

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by