Borrar filtros
Borrar filtros

Blockname in 2 lines

11 visualizaciones (últimos 30 días)
Malu
Malu el 29 de Ag. de 2023
Editada: Malu el 30 de Ag. de 2023
When trying to highlight the blocks in simulink model using hilite_system, it is showing errors for those blocks that has a new line in the string. For example, Instead of RelationalOperator, if the blockname is
Relational
Opeartor, it is showing errors for such blocks. Not opening the model and highlight the block. How can it read the complete blockname . The error i am getting is" Error: Character vector is not terminated properly." it is reading only till xx/yy/Relational
not the name in the second line. How can i avoid the error without changing the blockname?

Respuesta aceptada

Yash
Yash el 30 de Ag. de 2023
The issue you're encountering with hilite_system in Simulink is related to the way it processes block names with newline characters. By default, hilite_system and some other Simulink functions may not handle block names with newlines as you'd like.
However this issue can be addressed without changing the block name, one of the approach has been demonstrated below.
Approach : Treat new line characters as spaces :
Method 1 : Suppose the name of your block is
block_name = 'Relational
Operator'
While making the call to the hilite_system just replace the new line characters as spaces.
hilite_system('your_model_name/Relational Operator','fade')
This will highlight the block in your code.
Method 2 : Use Block Path
blockPath = getfullname('your_model_name/Relational Operator');
hilite_system(blockPath,'error');
This will also work as intended
Either of these approaches should allow you to highlight blocks with newline characters in their names without changing the block name itself.
I hope this helps.
  1 comentario
Malu
Malu el 30 de Ag. de 2023
Editada: Malu el 30 de Ag. de 2023
Hi,
Thanks for the suggestion. It works now.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by