https://uk.mathworks.com/help/matlab/ref/net.disableautorelease.html
NET.disableAutoRelease - Lock .NET object representing Runtime Callable Wrapper (COM wrapper) -...
This MATLAB function locks a .NET object representing a RunTime Callable Wrapper (COM wrapper) so that MATLAB does not release the COM object.
lockobjectrepresentingruntimecallable