Sorting distance traveled by timestamps
조회 수: 2 (최근 30일)
이전 댓글 표시
Zachary Wayne Liesemeyer
2019년 12월 6일
댓글: Zachary Wayne Liesemeyer
2019년 12월 6일
I am working on extracting distance traveled with timestamps from a json file from google maps timeline data.. i have first extracted the data and ran the lat and long data through dist11km tool box to find distance treaveled between each timestamp.
now i want to sum each days travel distance and plot for each day of the week. I was working on this to to sum the distance per day. The problem is that I I am finding the temp array empty and so I am not getting any data. how should I modify this to save the find into temp and run through the sum(d2km(temp))?
for j=1:22831
temp=find(single(datenum(projecttime(1,j)))>=single(datenum('01-Sep-2019 00:00:00'))...
&single(datenum(projecttime(1,j)))<=single(datenum('02-Sep-2019 00:00:00')));
dailydis1=sum(d2km(temp));
end
댓글 수: 0
채택된 답변
Guillaume
2019년 12월 6일
So, you've got easy to use datetime in your array and you go and convert to harder to use datenum and then to single. Why?
The easy way to do what you want is to store all three variables in a timetable and then retime it. I'm unclear why your projecttime has one more element than the other two, I'm discarding the last here:
traveleddistance = timetable(projecttime(1:end-1)', d1km(:), d2km(:), 'VariableNames', {'d1km', 'd2km'});
dailytravel = retime(traveleddistance, 'daily', 'sum')
Done!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!