How to speed up the computing time?
5 views (last 30 days)
Dear guys! My code is computationally to expensive and I'm looking for your help.
I have 3 input table with different legths in which each column represents:
1- position in X
2- position in Y
3- timestamp (in nanosec)
What I'm looking for is to create one table with the position in X and Y of the three tags with a common timestamp.
To do so I find the absolute maximum and minimum of the timestamps and then I create a coloumn vector as it follows A=min:seconds(5):max.
At this point, for each interval with the find function I check how many timestamp of the three tags belongs to it (es. find(A(i) > = tag3(:,3) & A(i+1)< tag3(.,3)). The output of the find thanks to the mean function allows me to calculate the mean position in X and Y inside this time interval.
I tested this procedure with a subset of my real data set and everything is as expected but unfortunately using my entire dataset It takes hours to be fully computed.
How could I speed up the entire running time?
Thanks to all of you in advance for your time ! :)
More Answers (1)
Walter Roberson on 19 Jul 2021
discretize() all of the A values at the same time, getting out group number G
Now you can
grpstats([X(:), Y(:)], G, @(x) mean(x,1))
and the result should be a max(G) by 2 array where first column is mean of X for the group and second column is mean of Y for the group.