| Algorithm 1 Matching-Basedmotif extraction algorithm. |
| Require: DM, the precomputed distance matrix with d(·), a dissimilarity metric; dth, the threshold for the matching definition; Ktarget, the maximum size for the Codebook. |
| for all m, n do |
| MMmn ← I(DMmn < dth) |
| end for |
| k ← 1 |
| while DM ≠ ∅ and k ≤ Ktarget do |
| for all m do |
| MCm ← ∑nMMmn |
| end for |
| i ← argmaxm(MCm) |
| X(k) ← T(i) |
| delete the l-th rows and columns in DM and MM for which MMil = 1 |
| k ← k+1 |
| end while |
| K ← k |