Hello,
As per my understanding, the finddelay function should not be returning 0 unless your signals 'r' and 'e' are already perfectly synchronized. It appears that the function is not working correctly for your particular signals, you can perform a manual cross-correlation by using the xcorr function to determine the time delay:
[acor, lag] = xcorr(e, r);
[~, I] = max(abs(acor));
time_delay = lag(I);
If time_delay is non-zero, this indicates the amount by which the signals need to be shifted to align them. If it is zero, but the signals are clearly not aligned, there may be an issue with the signals' content or the cross-correlation method may not be suitable.
After applying the bias correction and time alignment, plot the signals to visually inspect the synchronization. Also, calculate the correlation coefficient to quantify the synchronization:
correlation_coefficient = corrcoef(r_aligned, e_aligned);
Refer to the below documentation for more information on xcorr and corrcoef: