# How to match two signals that have similar shape but are scaled and expanded?

I have two signals A and B in time domain as follows: Visually both signals look very similar; however the X and Y axis range are different for both the signals. Signal B is basically a "stretched" version of signal A. The minimas, maximas occur at different x and y values; but relative distance between successive peaks of the signals have somewhat an uniform proportion.
I'm looking for a similarity metric that would give high similarity value for such pairs. Note dimensions of both signals are different. Due to the domain constraint, I cannot pad values to any of them. I tried cross correlation, circular correlation, and other common similarity measure but they didn't give satisfactory results.

• I've heard of the methodology at link below but don't know much about it. Still, it might be worth a look at. researchgate.net/publication/… May 15 '19 at 21:18
• If the Two signals mentioned in the above figure are discrete time signals, then please try resampling one of the signals. 1) Either downsample the second signal (with x-axis range over 250) or 2) Upsample the first signal (with x-axis range less than 200). Scaling the resampled signal by appropriate gain can help match both of them May 21 '19 at 7:17
• Will echo the answer below and comment above that Dynamic Time Warping is a very effective technique for this task. Good packages exist in R and Python if you're looking to try it out. May 24 '19 at 16:59
– A_A
Sep 6 '19 at 9:00

You can always match the extrema via a simple linear mapping, e.g. $$y[n] = \frac{x[n]-min(x[n])}{range(x[n])}$$ where $$range(\cdot)$$ is the absolute difference between the maximum and minimum values and $$x$$ is the input signal. This will get $$y \in [0 .. 1]$$ and then you can shift that interval to whatever (min,max) and baseline you like.