Hey guys,
I am splitting a column according to it's unique values:
[C, ia, ic] = unique(Location)
Which gives me (examplified):
C/ia/ic:
Location1 1205 8
Location2 9 8
Location3 387 2
Location4 45 2
Location5 653 8
Location6 59 8
Location7 3 1
Location8 1037 1
etc.. numbers may not match..
Now I have another colum containing DiffTime(seconds):
DiffTime:
0
23853
16835
12900
14869
40810
11700
10201
How can I add up DiffTime for each unique Location?
So that i get DiffTimeTotal for Location1, Location2, ...
Thanks for your help!!

 채택된 답변

Matt J
Matt J 2021년 5월 2일

2 개 추천

accumarray(ic, DiffTime)

추가 답변 (1개)

Matt J
Matt J 2021년 5월 2일

0 개 추천

Possibly faster:
totals = splitapply(@sum, DiffTime, findgroups(Location))

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 5월 2일

답변:

2021년 5월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by