Create a function named X.m that when given the argument 'load' loads the value of X from a file and puts it into a persistent variable and uses mlock
https://www.mathworks.com/help/matlab/ref/mlock.html
For any other argument, including no argument, index the persistent variable and return that result.
Limitations:
- does not permit the user to store into the variable
- does not permit use of end as an index
You can possibly improve on this by defining an object with subsref and subsasgn behavior.
You cannot simply mlock a variable however.
1 Comment
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/471508-is-it-possible-to-load-a-variable-that-can-not-be-cleared#comment_724021
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/471508-is-it-possible-to-load-a-variable-that-can-not-be-cleared#comment_724021
Sign in to comment.