How to create my own model callback function (InitFcn, StartFcn,...) in Model properties/Callbacks panel ?
Mostra commenti meno recenti
On the one hand, I ran a model A where paramaters were loaded (just before simulation) by a scirpt 'A_param.m' called by 'InitFcn' model callback. And everything works fine.
On the other hand, when one model is referenced by another one, I have a compilation error. For example, if we suppose that model A references model B. I noticed that 'InitFcn' callback from model B is executed before 'InitFcn' callback from model A, and parameters are still loaded by a scirpt called by 'InitFcn' model A callback. Then, Model B compilation fails because parameters are not yet loaded when compilation starts.
I cannot move scirpt A_param.m to 'InitFcn' callback from model A to model B because A_param.m has to belong to model A.
I cannot either move scirpt A_param.m to 'PreLoadFcn' or 'PostLoadFcn' callbacks because I want load parameters just before simulation.
I look for a solution as for example build my own model callback, for instance, 'PreInitFcn' which would be called before both 'InitFcn' callbacks to load parameters. Is it possible ?
Does anyone know an alternative solution to load parameters just before simulation but also before model B 'InitFcn' callback ?
Thanks in advance.
Risposte (1)
Kaustubha Govind
il 17 Lug 2012
0 voti
Sorry, it is currently not possible to introduce your own model callback. The PostLoadFcn is the latest option that you have before InitFcn is called. Would it be possible for you to separate B's parameters from A's, and put them in B's InitFcn callback instead? That seems like the scalable thing to do.
2 Commenti
Valery Carpentier
il 17 Lug 2012
Kaustubha Govind
il 18 Lug 2012
Valery: Please submit an enhancement request via Tech Support with your use-case for a "PreInitFcn" if you'd like the development team to be aware of this.
Categorie
Scopri di più su Model, Block, and Port Callbacks in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!