필터 지우기
필터 지우기

Simulink block name generation

조회 수: 8 (최근 30일)
Gagik Hakobyan
Gagik Hakobyan 2012년 3월 14일
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