필터 지우기
필터 지우기

Is there a classdef startup/initializer method?

조회 수: 2 (최근 30일)
James Tursa
James Tursa 2023년 9월 19일
편집: James Tursa 2023년 9월 20일
When a classdef is first loaded into memory (via object instance creation or static method call etc.), is there a way to get a startup/initializer method to automatically be called once? E.g., to do preliminary calculations needed to support the classdef functionality?

채택된 답변

Matt J
Matt J 2023년 9월 20일
편집: Matt J 2023년 9월 20일
As one example, you can initialize a property with a class-related function like below. Various other options are discussed here and here.
classdef myclass
properties (Constant)
startupData=init()
end
end
function data=init() %class-related function
%Do initial stuff here.
end
  댓글 수: 1
James Tursa
James Tursa 2023년 9월 20일
편집: James Tursa 2023년 9월 20일
I think this will work for me. Thanks!
(Although in my application, init( ) is a myclass static method so it must be called myclass.init)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by