필터 지우기
필터 지우기

How order my own Simulink library in folders?

조회 수: 2 (최근 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 CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by