Hello, Prashanth,
Thanks for your suggestion, I modified my code with your suggested code and ran the simulation, but the value of UDMI didn't change at every timestep, which means that the value of UDMI remains the same. The following picture is my code.