A simulation algorithm concerning problem B of 09 CUMCM is given. By introducing the concept of bed vector, clinic matrix, arrangement matrix and priority vector, the information about clinic, bed and arrangement will be stored and analyzed via MATLAB. By the algorithm the continuously updating of data has been simulated successfully.