Customize block callbacks error message

3 ビュー (過去 30 日間)
langrg
langrg 2020 年 3 月 11 日
編集済み: langrg 2020 年 3 月 20 日
Hello,
I want to specify the InitFcn of a Simulink block, for example 'MyInitFcn'. 'MyInitFcn' is an m file (function) that contains tests, and raises errors (using error Matlab function) with custom error messages, if those tests are bad.
When I run my Simulink (using run Matlab command), Simulink give me back an error window, but the error message does not contain my custom error message. It (more or less) gives me an message that the error comes from the InitFcn, but nothing about my custom error message .
I would like that, at least, part of Simulink error window message contains my custom error message. If it could only contain my custom error message, it would be better again.
Does anyone know how to solve my trouble?
Thanks!
GL.

回答 (1 件)

Shresth Sharma
Shresth Sharma 2020 年 3 月 18 日
Hi,
It is my understanding that you are trying to use ‘InitFcn’ callback from the model properties callback of the Simulink to run checks and give custom error messages. The ‘InitFcn’ callback should be used for declaring the variables in the workspace which are not defined and are needed at the time when you run the model. ‘InitFcn’ callback should not be used for checking the model or for commands that simulate the model. Try using ‘StopFcn’ callback for this task. The StopFcn callback will execute when a simulation stops by either running to completion or is stopped by the user.
Go through these documentation links for further details
  1 件のコメント
langrg
langrg 2020 年 3 月 20 日
編集済み: langrg 2020 年 3 月 20 日
Hi ,
No, I'm not talking about 'InitFcn' of a model, but 'InitFcn' of a Simulink block (right click, Properties/Callbacks).
I want to check parameters of this block, before simulation starts (just before compilation, when you call 'run' or 'sim' Matlab function).
Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by