release
Releases the resources of a System object and unlocks it.
Category: Programming > Classes
Syntax
release(obj)
Calls the object's releaseImpl, if any, and unlocks it so that properties and input sizes can change again.
Description
A System object becomes locked on the first call to step or setup. While locked, nontunable properties cannot be changed and the input data types and sizes are fixed. release ends that state: it runs the releaseImpl method, where a class closes files or frees buffers, and unlocks the object.
The object keeps its property values. The next step calls setupImpl again.
Input arguments
obj- A System object, an instance of a class derived from
matlab.System.
Example
Locking and releasing
writelines([ ...
"classdef Counter < matlab.System", ...
" properties", " Total = 0", " end", ...
" methods (Access = protected)", ...
" function setupImpl(obj)", " obj.Total = 100;", " end", ...
" function y = stepImpl(obj, u)", " obj.Total = obj.Total + u;", " y = obj.Total;", " end", ...
" function releaseImpl(obj)", " disp('released')", " end", ...
" end", "end"], 'Counter.m');
c = Counter;
step(c, 5);
isLocked(c)
release(c)
isLocked(c)
Output
ans = logical
1
released
ans = logical
0
The example first writes the small System class Counter to the current folder.
Notes
release as described here applies to System objects.