Simulink block name generation

8 次查看(过去 30 天)
Hello all, I have a model block handle h in my design and would like to get its full path (like its gcb value). s = get(h); p = [s.Path, '/', s.Name]; This fragment works fine if the block name does not contain slashes. For example, if block name is 'b/c', and path = 'a', then i get 'a/b/c', but if i select the block, its gcb value is 'a//b/c' (with double slashes).
I would like to get correct full path without any checking in block name. any ideas?, please help.
Regards, Gagik

采纳的回答

Kaustubha Govind
Kaustubha Govind 2012-3-14
I think the forward slash is used as an escape sequence to denote that the slash in the block name is part of the name, to avoid confusing it with another subsystem level.
For example, if I have a block named 'b/c' in a model called 'a', gcb will return 'a/b//c', because if it returned 'a/b/c', this could be interpreted as a block called 'c' in a subsystem called 'b' which is inside a model called 'a'.
Why would you like to avoid the escape sequence? I think you will have trouble using something like 'a/b/c' to denote the above described block, because Simulink won't be able to find a subsystem called 'b'. In any case, if you still want to remove the escape sequences, you need to do some string manipulation yourself. One simplistic way of doing this is: strrep(gcb, '//', '/'), but this doesn't handle multiple slashes, like in 'a/b////c'.
  1 个评论
Gagik Hakobyan
Gagik Hakobyan 2012-3-15
Thanks for the reply, yes, actually i have block name ('b/c') and block path ('a') values, and would like to get its gcb value ('a/b//c', and if i concatenate block path and name values, will have 'a/b/c').

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by