Simulink block name generation
5 次查看(过去 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
0 个评论
采纳的回答
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'.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!