**Appendix A. MATLAB Code for Force and Velocity Data Realignment**

This appendix provides the MATLAB (R2016a, The MathWorks, Natick, U.S.) script that can be applied to realign force and velocity timeseries for *CD* derivations.

```
for i=1:3 % number of Synchronized Force–Velocity Measurement systems
  NN=0;
  D=0;
  DD=0;
  while NN<=30 % number of loops
    NN=NN+1
    Delay(i,NN)=round(abs(DD)+D);
%Adjust the velocity bases on the phase difference, while keep the force is not change
      if i==1
        secADV1=AllADV1new(orpo1−Delay(i,NN):orpo1+8*TT*80−Delay(i,NN),:);
        secADV(:,1)=secADV1(:,2);
      end
      if i==2
        secADV2=AllADV2new(orpo2−Delay(i,NN):orpo2+8*TT*80−Delay(i,NN),:);
        secADV(:,2)=secADV2(:,2);
      end
      if i==3
```

```
secADV3=AllADV3new(orpo3−Delay(i,NN):orpo3+8*TT*80−Delay(i,NN),:);
  secADV(:,3)=secADV3(:,2);
end
% Calculation of inertia force
  Fm(:,i)=2*1000*pi*0.02*0.02*hv*(diff(secADV(:,i))/0.0125)/4;
% Calculation of drag force
  Fd(:,i)=secCLN(2:end,i)−Fm(:,i)
%Calculation of in−time Cd
  Cd(:,i)=2*Fd(:,i)./(1000*0.02*hv*secADV(2:end,i).*abs(secADV(2:end,i)));
%Intercept the peak value of velocity
  [maxE,minE]=peakdet(secADV(:,i),0.3*(max(secADV(:,i))−min(secADV(:,i))));
%Intercept the peak value of drag force
  [maxFd,minFd]=peakdet(Fd(:,i),0.3*(max(Fd(:,i))−min(Fd(:,i))));
if maxE(1)<10
  for kk=2:length(maxE)
    maxE(kk−1)=maxE(kk);
  end
maxE(kk)=NaN;
end
if minE(1)<10
  for kk=2:length(minE)
    minE(kk−1)=minE(kk);
  end
minE(kk)=NaN;
end
if maxFd(1)<10
  for kk=2:length(maxFd)
    maxFd(kk−1)=maxFd(kk);
  end
maxFd(kk)=NaN;
end
if minFd(1)<10
  for kk=2:length(minFd)
    minFd(kk−1)=minFd(kk);
  end
minFd(kk)=NaN;
end
loc_E(:,i)=cat(1,maxE(1:2,1),minE(1:2,1));
loc_Fd(:,i)=cat(1,maxFd(1:2,1),minFd(1:2,1));
%Phase difference between drag force and velocity
delay(i,NN)=mean(loc_E(:,i)−loc_Fd(:,i))
clear maxFd minFd maxE minE
    D=abs(delay(i,NN));
    DD=Delay(i,NN);
```

```
end
```
end
