Borrar filtros
Borrar filtros

How to programmatically comment/uncomment a Simulink block?

219 visualizaciones (últimos 30 días)
Joe
Joe el 9 de Dic. de 2015
Comentada: madhan ravi el 30 de Mzo. de 2024
Simulink blocks can be commented/uncommented using Ctrl+Shift+X.
Is there a way to do this programmatically in a Matlab script?
  3 comentarios
Akhilesh
Akhilesh el 30 de Mzo. de 2024
how to pogrammatically comment and uncomment all the blocks in the simulink model ?
madhan ravi
madhan ravi el 30 de Mzo. de 2024
@Akhilesh I am not sure if the following works:
ModelName = 'my_model.slx'; % here you put the name of your Simulink model
set_param(ModelName,'Commented','on')
set_param(ModelName,'Commented','off')
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.

Iniciar sesión para comentar.

Respuesta aceptada

Sebastian Castro
Sebastian Castro el 9 de Dic. de 2015
Yes, you can do
set_param(blockName,'Commented','on')
set_param(blockName,'Commented','off')
... or if the block has 1 input and 1 output port, you can also comment through
set_param(blockName,'Commented','through')
Here, blockName is the name of the block, which you can obtain by selecting the block and typing gcs.
- Sebastian
  3 comentarios
Mike Crawford
Mike Crawford el 20 de Mayo de 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 el 27 de Jun. de 2020
Excellent. I was lost in the myriad parameters each block / component has.
set_param([gcs,'/L(',num2str(k),')'],'Commented','on')
selects L(k) from the current system and comments it out.

Iniciar sesión para comentar.

Más respuestas (1)

RAGHUVEER RAJESH
RAGHUVEER RAJESH el 21 de Sept. de 2023
Editada: RAGHUVEER RAJESH el 21 de Sept. de 2023
The path value has to be passed as a string. So put the path in ' ' single inverted commas.
For e.g.
set_param('subsystempath','Commented','on')
set_param('subsystempath','Commented','off')
the 'subsystempath' is full path to that subsystem. For e.g. 'modelName/subsystemName...'
If it helps, please let me know...

Categorías

Más información sobre Interactive Model Editing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by