add ind2sub and finish the functions of zhou's code