MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

end
end


methods (Access = protected)
% In setup allocate any resources, which in this case is
% opening the file.
function setupImpl(obj)
obj.pFileID = fopen(obj.Filename,obj.Access);
if obj.pFileID < 0
error("Opening the file failed");
end
end


% This System object writes the input to the file.
function stepImpl(obj,data)
fwrite(obj.pFileID,data);
end


% Use release to close the file to prevent the
% file handle from being left open.
function releaseImpl(obj)
fclose(obj.pFileID);
end
end
end


See Also


nargin | setProperties


Related Examples



  • “Define Property Attributes” on page 34-32

  • “Release System Object Resources” on page 34-30


See Also
Free download pdf