This time I tried a different code for maximum value. It takes a very long time to run, about 30 minutes. I don't even know if your conclusion is correct.
load("Green6000X.csv")
b12xtime=Green6000X(:,1);
b12xacc=Green6000X(:,2);
lastValueOfTime=ceil(b12xtime(end));
for ii=0:lastValueOfTime
for i=1:height(b12xtime)
a=find(b12xtime(:,1)<=i);
b=find(b12xtime(:,1)<=i+1);
t(i,1)=height(a);
s(i,1)=height(b);
% val=abs(s-t);
for x=t(i):s(i)
c(x,1)=b12xacc(x,1);
d=max(c);
v(x,1)=d;
if(v(x-1,1)==v(x,1))
v(x-1,1)=0;
end
end
end
end
for i=1:length(column)
column= find(v==0);
v(column(1),:) = [];
end