A new block named 'modelName/blockName' cannot be added.

Hello,
I am using Matlab 7.10.0.499 (R2010a) and have a strange bug.
When I launch my program, I got an error "A new block named 'modelName/blockName' cannot be added." When I comment out the line "add_block('blockPath', 'modelName/blockName' ), the program works. More strangely, if I write the same line in console the block is added to the model with no error.
Anyone has any idea why it does not work? Is there any concurrency issues or something like that?
Regards

 採用された回答

TAB
TAB 2012 年 6 月 27 日

4 投票

It could be due to the reason, you are trying to add a block with the name which already exists in the destination path.
To avoid the possibility of adding block with sane name, set MakeNameUnique property to on.
add_block('blockPath', 'modelName/blockName' ,'MakeNameUnique', 'on');

1 件のコメント

Youssef
Youssef 2012 年 6 月 27 日
Thanks for the suggestion. It helped me find the error. I forgot that I used a vector instead of a scalar and for this reason draws two times the same block. Thanks!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgrammatic Model Editing についてさらに検索

製品

質問済み:

2012 年 6 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by