Added simulation code and added new functions to multi_Scan.r