Running model callbacks in model workspace
이전 댓글 표시
Noticed that model callbacks such as PostLoadFcn, StartFcn etc run in base workspace, and they cannot access variables defined in model workspace unless they are evalin'ed in model workspace. Is there a way to change this behaviour and tell the model to evaluate the expressions of its model callbacks in the model workspace instead?
답변 (1개)
Ryan G
2013년 5월 13일
0 개 추천
I don't believe you can change the default behavior here. How much extra work is using the evalin function? Are you calling a lot of functions in the callbacks?
댓글 수: 5
Ryan G
2013년 5월 13일
I think the complication may stem from the fact it's calling the MATLAB interpreter to perform the callback. When looking at the callback, I would think of it as a way of saying, when this event occurs (PostLoad), send these commands to the MATLAB command window. It may not be ideal in this instance, but that's how it's behaving.
If you are loading data, you can save that in the model workspace and avoid a callback.
If you are using evalin to load something in the model workspace then you are creating a new variable as part of the model and hence dirtying the model. I may not understand what you are doing here though.
카테고리
도움말 센터 및 File 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!