How to add a custom library using add_block?

Hi, I created a custom library. This library contains only one subsytem block named RADAR. I am trying to use add_block and add this subsytem. Without any error the simulink file opens but the block does not appear. This is how I load my library.
load_system('libdeneme');
And these are some of the code lines I tried.
add_block('simulink/libdeneme/RADAR','autoCreateDeneme')
add_block('simulink/libdeneme/RADAR','autoCreateDeneme')
add_block('libdeneme/RADAR','autoCreateDeneme')
add_block('libdeneme/RADAR',)

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2019 年 10 月 10 日

0 投票

Your syntax is not correct.
open_system('SourceLibFileName')
add_block('SourceLibFileName/RADAR','DestModelFileName/BlockName')

5 件のコメント

Sinem Erdogan
Sinem Erdogan 2019 年 10 月 10 日
This is still not working. My new simulink project opens but the screen is empty. No blocks are placed.
Fangjun Jiang
Fangjun Jiang 2019 年 10 月 10 日
Make sure your library model is loaded or opened. Make sure whatever your new model is created or opened, and then run the add_block() command.
Sinem Erdogan
Sinem Erdogan 2019 年 10 月 11 日
I tried it again and it is still not working. Here is my coding.
>> open_system('libDeneme')
>> new_system('deneme')
>> save_system('deneme')
>> open_system('deneme')
>> add_block('libDeneme/RADAR','deneme/please')
There is no block named 'libDeneme/RADAR'
>> load_system('libDeneme')
>> add_block('libDeneme/RADAR','deneme/please')
There is no block named 'libDeneme/RADAR'
>> blockNames = find_system('libDeneme', 'Type', 'Block')
blockNames =
1×1 cell array
{'libDeneme/RADAR↵'}
Fangjun Jiang
Fangjun Jiang 2019 年 10 月 11 日
You have an extra character "↵" in the block name in the library, most likely a carriage return. Remove it.
Sinem Erdogan
Sinem Erdogan 2019 年 10 月 11 日
Thank you. This solved the problem.

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

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

製品

リリース

R2018b

質問済み:

2019 年 10 月 10 日

コメント済み:

2019 年 10 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by