You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
In matlab, when a variable passed into a function is modified within the function, a copy of the variable is created on the fly, unless the variable is completely a temporary variable or unless the same variable is retrieved as an output argument.
detach() is a very simple function to clear the variable from the caller workspace and convert it into a temporary variable that is not accessible anymore upon return from the function call. If variable doesn't exist in another workspace, this avoids copy-on-write. detach() can also be handy for code clarity.
Cite As
Gokberk Cinbis (2026). detach - clear variable while passing to a function (https://se.mathworks.com/matlabcentral/fileexchange/34246-detach-clear-variable-while-passing-to-a-function), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (1.56 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 |
