How order my own Simulink library in folders?
3 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Zack Peters
on 8 Nov 2013
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
0 Comments
See Also
Categories
Find more on Schedule Model Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!