I have two matrices: matrix {a} <252×1> is a subset of matrix {b} <252×4000>. I need to determine the number of days before and after the values of matrix {a} occurred in matrix {b}.
Example:
Matrix a Matrix b
10 12 34 54 10
23 23 98 78 98
43 98 53 43 88
44 98 44 88 78
Output
1 1 1 10
23 1 1 1
1 1 43 1
1 44 1 1
Days
3 0
0 3
2 1
1 2
This answer assumes there is only one match per row:
If the assumption is bad then I think you’ll be better off using loops.