Effacer les filtres
Effacer les filtres

Simulink block name generation

8 vues (au cours des 30 derniers jours)
Gagik Hakobyan
Gagik Hakobyan le 14 Mar 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

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 14 Mar 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 commentaire
Gagik Hakobyan
Gagik Hakobyan le 15 Mar 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').

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by