generate matrix