How order my own Simulink library in folders?

3 ビュー (過去 30 日間)
Carlos
Carlos 2013 年 11 月 8 日
回答済み: Zack Peters 2013 年 11 月 8 日
I have already my library (.mdl) with several blocks and I need to order it. I have saw that I can make subsystems to see folders at "Simlink Library Browser".
My problem is that if I do it, the links are broken in models that I have done before the changes.
Any idea. Thanks in advance!

回答 (1 件)

Zack Peters
Zack Peters 2013 年 11 月 8 日
Unfortunately, there is no easy way to do this. If you double click on the bad link in one of your models, you can see that its pointing to a specific path and that path had been modified by creating a subsystem.
You could create a script which will find all of the bad links in your model, find the name of the block that it was pointing at (libName/blockName), and then find the new block.
I created a very rough demo script which gets the job done on a simple test case that I create. Give it a try and see how it works:
myModel = % Name of your model
myLib = % Name of you library
x = find_system(myModel,'FindAll','on','type','block','BlockDescription','Unresolved library reference.');
for i = 1:numel(x)
source_block_path = get_param(x(i),'SourceBlock');
[~,source_block,~] = fileparts([source_block_path '.blah']);
lib_block_handle = find_system(myLib,'FindAll','on','type','block','Name',source_block);
set_param(x(i),'SourceBlock',[get_param(lib_block_handle,'Parent') '/' get_param(lib_block_handle,'Name')])
end
Hope this helps,
~Zack

カテゴリ

Help Center および File ExchangeSchedule Model Components についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by