function acc_cost_mat = acc_cost_matrix_region(cost_matrix,region)
    n_timestamps_1 = size(cost_matrix,1);
    n_timestamps_2 = size(cost_matrix,2);
    
    acc_cost_mat = inf(n_timestamps_1, n_timestamps_2);
    
    acc_cost_mat(1, 1:region(2, 1)) = cumsum(cost_matrix(1, 1:region(2, 1)));
    acc_cost_mat(1:region(2, 1), 1) = cumsum(cost_matrix(1:region(2, 1), 1));
   
    region_ = max(2, region);
    
    for i = 2:n_timestamps_1
        for j = region_(1, i):region_(2, i)
            acc_cost_mat(i, j) = cost_matrix(i, j) + ...
            min([acc_cost_mat(i - 1, j - 1) acc_cost_mat(i - 1, j)...
            acc_cost_mat(i, j - 1)]);
        end
    end    
end

