필터 지우기
필터 지우기

Rerunning Setup Method When Using System Objects

조회 수: 3 (최근 30일)
Leon
Leon 2022년 5월 17일
답변: Infinite_king 2023년 10월 6일
I am using System Objects where some of the properties are initialised in the setupImpl method. The issue is that sometimes on the first iteration some of the System Objects in a cascade receive empty values as an input. As a result setupImpl method can't be run properly. Is there a way to rerun setupImpl method or skip it if the input is empty.

답변 (1개)

Infinite_king
Infinite_king 2023년 10월 6일
Hello Leon,
I understand that you would like to execute the 'setupImpl' function on a system object after the initial setup of the object is completed.
You can achieve this by using the 'setup' function as shown below in the following code snippet,
% obj is the system object
% input1, inputN .. are the sample inputs to validate
setup(obj,input1,...,inputN);
The 'setup' function also performs additional validation of input arguments. For a detailed call sequence, please refer to the following link: https://www.mathworks.com/help/matlab/matlab_prog/call-sequence.html#:~:text=Call%20Sequence.-,setup%20Call%20Sequence,-When%20you%20run
The 'setupImpl' function is executed the first time the system object runs. In some cases you can skip 'setupImpl,' by include a bypass statement as follows
function setupImpl(obj)
if obj.StartValue == not_invalid_value
.
.
% Setup operations
.
.
end
end
For more information, please refer the following documentation,
  1. https://www.mathworks.com/help/matlab/ref/setup.html
  2. https://www.mathworks.com/help/matlab/matlab_prog/call-sequence.html
  3. https://www.mathworks.com/help/dsp/ref/cascade.html
Hope this is helpful.

카테고리

Help CenterFile Exchange에서 Create System Objects에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by