Filter löschen
Filter löschen

Simulink block name generation

8 Ansichten (letzte 30 Tage)
Gagik Hakobyan
Gagik Hakobyan am 14 Mär. 2012
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

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 14 Mär. 2012
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 Kommentar
Gagik Hakobyan
Gagik Hakobyan am 15 Mär. 2012
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').

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by