Sorting distance traveled by timestamps
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Zachary Wayne Liesemeyer
el 6 de Dic. de 2019
Comentada: Zachary Wayne Liesemeyer
el 6 de Dic. de 2019
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 comentarios
Respuesta aceptada
Guillaume
el 6 de Dic. de 2019
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!
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!