how to change the reference of linked block..

Hello all.
I need some advice...
I made a link block which refers to a block in another lib file. (This link made by my dragging of the block from lib.mdl file to a.mdl)
is there any way to change this link manually like using set_param command. To make this problem clearly, I'd like to give you an simple example.
"a.mdl" has a linked block whose name is "target" that refers to "lib/target_a" block(lib.mdl file has target_a). And I want to change this linked block referring to "lib/target_b" block through command window
Simply, this is equivalent to change the value of "SourceBlock" in "a.mdl" file.
I did many googlings to find the answer of my question, but I couldn't get closer. I guess.. this type of control path would not be opened for users....
is there any suggestion or comment for this?
Thanks in advance..

 採用された回答

Guy Rouleau
Guy Rouleau 2012 年 11 月 19 日

2 投票

This should do it:
set_param('a/target','referenceBlock','lib/target_b')
This is mentioned here:

2 件のコメント

Jonghun
Jonghun 2012 年 11 月 20 日
It works!
Thanks again.
Kaustubha Govind
Kaustubha Govind 2012 年 11 月 26 日
Nice!

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

その他の回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 11 月 19 日

1 投票

I don't imagine that this would be allowed with a simple set_param command because it might mean that things could go wrong with how library links work. One way to do this might be to use delete_block and add_block to physically replace the block.

1 件のコメント

Jonghun
Jonghun 2012 年 11 月 20 日
You're right. We should use carefully .. this kind of internal value changing.. But I checked this was not impossible.
Anyway, thanks for your answer.

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

カテゴリ

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

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by