Filter löschen
Filter löschen

How to programmatically comment/uncomment a Simulink block?

246 Ansichten (letzte 30 Tage)
Joe am 9 Dez. 2015
Kommentiert: madhan ravi am 30 Mär. 2024
Simulink blocks can be commented/uncommented using Ctrl+Shift+X.
Is there a way to do this programmatically in a Matlab script?
  3 Kommentare
Akhilesh am 30 Mär. 2024
how to pogrammatically comment and uncomment all the blocks in the simulink model ?
madhan ravi
madhan ravi am 30 Mär. 2024
@Akhilesh I am not sure if the following works:
ModelName = 'my_model.slx'; % here you put the name of your Simulink model
Because in documentation it only mentions about commenting out a block. But even so be the case, you can simply engulf your whole model into a Subsystem and simply comment out that Subsystem block.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sebastian Castro
Sebastian Castro am 9 Dez. 2015
Yes, you can do
... or if the block has 1 input and 1 output port, you can also comment through
Here, blockName is the name of the block, which you can obtain by selecting the block and typing gcs.
- Sebastian
  3 Kommentare
Mike Crawford
Mike Crawford am 20 Mai 2019
To add to this, it can save an additional step by selecting the block and typing "gcb" instead of "gcs".
Dick Benson
Dick Benson am 27 Jun. 2020
Excellent. I was lost in the myriad parameters each block / component has.
selects L(k) from the current system and comments it out.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

RAGHUVEER RAJESH am 21 Sep. 2023
Bearbeitet: RAGHUVEER RAJESH am 21 Sep. 2023
The path value has to be passed as a string. So put the path in ' ' single inverted commas.
For e.g.
the 'subsystempath' is full path to that subsystem. For e.g. 'modelName/subsystemName...'
If it helps, please let me know...


Mehr zu Interactive Model Editing finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by