Could you please let me know the possible reason for the error? Not only this time but I face this type of error many times. So, the solution could be really helpful for me.
Thank you
You mentioned that you are using Pluto.jl, so my guess is that there is probably another cell in your notebook modifying any of the variables resulting in the error.
You need to show us enough code so we can reproduce the error. What the message is saying is that you try to index into an empty vector, so it would appear that XYnew becomes empty at some point in your loop.