It sounds like you're trying to find and visualize the time lag between the peaks in two datasets. Here’s a step-by-step approach you can follow using MATLAB:
1. Find Peaks in Both Datasets:
Use the `findpeaks` function to identify the peaks in both series.
[pks_x, locs_x] = findpeaks(x, 'MinPeakDistance', 8);
[pks_y, locs_y] = findpeaks(y, 'MinPeakDistance', 8);
2. Compute Time Lag:
Calculate the time lags between corresponding peaks in `x` and `y`.
time_lag = locs_y - locs_x;
3. Plot the Time Lag:
Plot the time lag to visualize the differences.
plot(locs_x, time_lag, 'o-');
xlabel('Time (s)');
ylabel('Time Lag (s)');
title('Time Lag Between Peaks in x and y');
You might need to adjust the `MinPeakDistance` parameter in `findpeaks` according to your data. The example above assumes a distance of 8 based on your description.