added method to generate discrete matrix