Added: construct_q_matrix.m