Why does SelectCallback run during model build?
8 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Custom Software for Target Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!