updating algorithm DiscretizeMatrix and the example