Hello,
To speed up the code execution, following are a few suggestions which you can use:
- Instead of plotting during each iteration (which is slow), store the data in each loop and create the plot after the loop finishes.
- If you still need to update a plot inside the loop (e.g., for animation), use "drawnow limitrate" to reduce the frequency of GUI updates. This limits the redraw rate and prevents MATLAB from refreshing the figure on every single iteration.
Refer to the documentation page of the "drawnow" function for more details regarding "drawnow limitrate": https://www.mathworks.com/help/matlab/ref/drawnow.html
I hope this resolves your issue!
Thanks