how to get the current model design in matlab?

6 ビュー (過去 30 日間)
Atul
Atul 2025 年 4 月 17 日
コメント済み: Paul 2025 年 4 月 21 日
When you add a block to a Simulink canvas, the block handle typically refers to the library from which the block originates. How can I determine the name of the model or canvas where the block is being added?
For example, if you add a block named 'BlockA' to an untitled model, bdroot refers to the library, rather than the untitled model. How to get the name of the design into which the block is being added?

回答 (1 件)

Paul
Paul 2025 年 4 月 20 日
Hi Atul,
After a block is added to a Simulink diagram one can use bdroot(element) to get the name of the model in which the element resides. The element argument can be any one of several forms that idenitifies a block (or it can be an array). Is there reason to think bdroot works otherwise?
  2 件のコメント
Atul
Atul 2025 年 4 月 21 日
移動済み: Paul 2025 年 4 月 21 日
Hi Paul,
bdroot is giving diff results in debug mode. When teh breakpoint is added so bdroot will give the name of the model in which block is added but in normal flow it is giving the library name
I want to use bdroot(handle) in the block callback, but when I use it it is giving library name instead of design name. How can I get the name of a current design in which the block is added irrespective of the normal and debug flow.
Paul
Paul 2025 年 4 月 21 日
Debug mode of what? Debugging a Matlab script or function? Or debugging a Simulink model using the Simulink debugger?
Breakpoint added where?
What is normal flow?
Block callback of which block? Which callback?
How is the block being added to model?
I think specific details of the workflow are needed in order for anyone to try to recreate the problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by