MATLAB Answers

Matlab, automatically delete the index variable after the execution of a loop, Part 2

31 views (last 30 days)
alpedhuez on 19 Dec 2020
Commented: alpedhuez on 20 Dec 2020
suppose I have a loop
for i=1:10
then I want to clear the index variable 'i'. One way is to do
clear i
But is there a simpler way?


Show 2 older comments
John D'Errico
John D'Errico on 19 Dec 2020
I agree. Clearing the variable is just a waste of CPU cycles, however you might do it. Why bother?
Steven Lord
Steven Lord on 20 Dec 2020
then I want to clear the index variable 'i'
Why? What benefit do you hope to gain from doing this?
alpedhuez on 20 Dec 2020
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.

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 19 Dec 2020
That is the simpler way.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by