How is this part 2, since you asked identically the same question on stackoverflow? Is this just a general survey of every possible site, in case you can get a different answer? You cannot automatically delete a loop index variable after a loop. This is part of the language, and expected.
The simple answer is to just learn to use functions, then all of your spurious variables go away.
I agree that it will not matter from the execution perspective. But I need to send a script to a person and that person is not a programmer. So I need to clean up eveything as much as I can.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
5 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217720
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217720
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217735
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217735
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217850
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1217850
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1218090
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1218090
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1218630
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/698220-matlab-automatically-delete-the-index-variable-after-the-execution-of-a-loop-part-2#comment_1218630
Sign in to comment.