function cost_mat = cost_matrix_region(x,y,region)
    n_timestamps_1 = length(x);
    n_timestamps_2 = length(y);
    
    cost_mat = inf(n_timestamps_1, n_timestamps_2);
    for i = 1:n_timestamps_1
        for j = region(1, i):region(2, i)
            cost_mat(i, j) = norm(x(:,i) - y(:,j));
        end
    end
end

