How do you programmatically invoke model callbacks?

조회 수: 1 (최근 30일)
Phil
Phil 2012년 6월 12일
For organizational purposes, I've defined my Simulink model's PreLoad callback expressions in the model explorer's callback pane directly, and NOT broken them out into a separate script file (so that all the necessary info is contained in the .mdl file). I'd also like to re-invoke the expressions IF the workspace has been cleared between the time the model was opened and the time it was run. So, I'd love a way to generically run the contents of the PreLoad pane without copying all of it into the InitFcn pane. Does anyone know of a way to programmatically run a model's callback function with a generic command?
I figured there would be a command similar to setting a model's simulation command to 'start', but I can't find a corresponding parameter for a model's callback.

채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 6월 13일
Kind of a hack, but this should work:
>> eval(get_param(bdroot, 'PreLoadFcn'))
  댓글 수: 2
TAB
TAB 2012년 6월 14일
Perfect...
Phil
Phil 2012년 6월 14일
I'm not too worried about a method being a 'hack', as long as it's a generic, reusable 'hack'. This works perfectly, thank you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by