If i have 2 functions, let's say f(x) and g(x) and i want to find the longest portion of f that is similar to some portion of g, how can i do that?
For example, consider the figure below:
it is pretty evident they are enough similar to each other in the starting position, but what if they where in random position?
That's the point, i need to discover the longest similar portion(s) ... some hints?
In my case the two "functions" are an array rappresentation of two songs, and i want to find the most similar part of them, so they are supposed to be
You can do that by using cross-correlation (xcor).
This method computes the correlation of 2 signals for each "offset" between them. The highest correlated point will be the offset you need to give to signal2
to match signal1
. Read the documentation for examples and usage.