How can I lock a block in Simulink?

I wrote my own library, with one S-Function Block in Simulink. I want that it is possible to insert the block once in a Simulink Model, but not a second time (in the same model). I want that the my block is unique in the model. I need the block for some settings. Is there a chance to do that?

 采纳的回答

Andreas Goser
Andreas Goser 2013-7-30

0 个投票

I suppose there is no way to present inserting the block a second time, but you can verify if more than one block of this type exists right before running the model. You would need to apply MATLAB code with e.g. the "find_system" command as a model callback .

3 个评论

You find model callback in File -> Model Properties. You can use e.g. "StartFcn"
With "find_system" I can see if there are more than one blocks. Is it possible to delete, or remove the second one?
Yes. There are more Simulink API commands. Here DELETE_BLOCK

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by