Why does SelectCallback run during model build?

조회 수: 4 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2018년 3월 26일
답변: MathWorks Support Team 2018년 4월 18일
In a custom TLC file, we can specify a callback with "rtwgensettings.SelectCallback", which gets executed when the TLC file is selected. The documentation states:
"The SelectCallback function is triggered when the user selects a target with the System Target File browser."
However, this callback also executes when building the model. Is this expected behavior? If so, is there a way to prevent this callback from executing on model build?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 3월 26일
This is expected behavior for SelectCallback. As a workaround, you can use the "dbstack" function inside of the callback function to determine if code generation is occurring when the callback is being triggered. For example:
function mySelectCallback(hDlg, hSrc)
s = dbstack;
if ~ismember('build_target.p',{s.file})
disp('Running SelectCallback!!!\n');
% perform callback function logic as intended here
else
% do nothing if 'build_target.p' is in the callstack
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Custom Software for Target Hardware에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by