modified code test_simulation.m