Blockname in 2 lines

5 次查看(过去 30 天)
Malu
Malu 2023-8-29
编辑: Malu 2023-8-30
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?

采纳的回答

Yash
Yash 2023-8-30
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 个评论
Malu
Malu 2023-8-30
编辑:Malu 2023-8-30
Hi,
Thanks for the suggestion. It works now.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by