Get only block name from get() function

1 回表示 (過去 30 日間)
Ewela
Ewela 2021 年 10 月 27 日
回答済み: Shreshth 2025 年 1 月 17 日
How can I get only the name of the block without the port number?
I have this line:
blockname_and_portnum = get(line_connection_handler,'SourcePort');
and it gives me:
Step:1
but I need only Step. I want to get this without any extractBefore functions for code optimization. It is possible to get only block name from the function get()?

回答 (1 件)

Shreshth
Shreshth 2025 年 1 月 17 日
Hi Ewela,
There is no direct way to get the block name from a line handler without using any string manipulation functions in MATLAB. The block name and port number are typically returned as a single string, so some form of string manipulation is necessary to extract just the block name.

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by