Updated: construct_q_matrix.m