Set option to move deleted files to recycle folder
stat = recycle
previousStat = recycle state
previousStat = recycle('state')
recycle displays the current state, on or off, for recycling files you remove using the delete function. When the value is on, deleted files move to a different location. The location varies by platform—see Deleting Files and Folders Using Functions. When the value is off, the delete function permanently removes the files. For details, see the Tips section.
Start from a state where file recycling is off. Verify the current recycle state:
recycle ans = off
Turn file recycling on. Delete a file and move it to the recycle bin or temporary folder:
recycle on; delete myfile.txt
The preference for Deleting files sets the state of the recycle function at startup. When you change the preference, it changes the state of recycle. When you change the state of recycle, it does not change the preference. Use recycle to override the behavior of the preference. For example, regardless of the setting for the Deleting files preference, to remove thisfile.m permanently, run:
After setting the recycle state to off, all files you delete using the delete function are deleted permanently until you do one of the following:
Restart MATLAB. Upon startup, MATLAB sets the state for recycle to match the Deleting files preference.