开发者

Disable/Comment a block in Simulink

Is it possible to comment out the block in Simulink like it is possible in any programming languages ? I mean, using logic, I can disable the block. but its no开发者_JAVA技巧t the best solution all the time.

I would rather disable / comment out the part of the block in my Model to test individual modules in Simulink.


I just wanted to add that in Simulnk 2012b, it is now possible to explicitly comment out blocks. Simply right-click on the block and select the option "Comment Out".

When run, the model will act as if the commented out block is not there at all. This means that input/output signals to/from this block are essentially just left open. So for example, if you commented out a gain block, the input signal would not simply pass through to the output signal.


I found a potentially useful solution in the matlab central forums.

A good way to "comment out" Simulink blocks is to use a switch block whose control port is driven by a global constant value (parameter). Say PARA=1 if you want to have this Simulink block in your code and PARA=0 if you want to comment it out. Choose the threshold of your switch w.r.t the value of PARA. The first branch of the switch should pass the original signal to the Simulink block you want to have. The other should end at a terminator block. In this case, no code is executed for the Simulink block you want to comment out. And if you use a code generator, the code generator can decide in advance, whether you want to generate code for this block or not (depending on the value of PARA).

Original Source

Hopefully that will work for you as well.


Matlab / Simulink r2018A:

1) Select a simulink block.

2) Edit -> Comment Out:

Disable/Comment a block in Simulink

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜