Forget all known references or find all potentially broken references
2 次查看(过去 30 天)
显示 更早的评论
I run scripts over multiple models, where the models get loaded in various orders. Assume in model1 there is a reference, that gets resolved, if I load model2 before model1 (get_param(block, 'ReferenceBlock') == 'qlib/...'). If (after a clean start of Matlab) I open only model1 however, the references is broken (get_param(block, 'ReferenceBlock') == 0x0 empty char array).
Is there a way to either:
1: Clear the cache of known references? I tried clear all, bdclose all; close_system; Simulink.LibraryDictionary.clear; Simulink.LibraryDictionary.resetLibraryLinks to no avail. Apparently MATLAB keeps track of known references somewhere else. The only way, I managed was to restart MATLAB.
2. Find out if a Reference is not self-contained, even if currently resolved, i.e. broken without loading some other model? I did not find a good get_param property for this.
0 个评论
采纳的回答
Devon
2023-11-10
Question 1:
MATLAB has a rehash function that can reset the cache. https://www.mathworks.com/help/matlab/ref/rehash.html
rehash toolboxcache
Question 2:
This might be what you are looking for. https://www.mathworks.com/help/simulink/slref/find_mdlrefs.html
find_mdlerefs('modelName')
This will find referenced models and Model blocks for all models referenced by the specified model. It will provide an error when a link is broken.
3 个评论
Devon
2023-11-13
Ahhh! Those are library links, not model refs so the above wouldn't error out. Here are some resources on library blocks and their links.
Part 1:
I think this first link is what you are looking for. Look at the section for "link status":
You can also take a look at the following link to find some other ways to check info on library blocks (and other simulink blocks in general): https://www.mathworks.com/help/simulink/slref/find_system.html
- Blocks linked from libraries have a parameter called "ReferenceBlock" which indicates the library and block that this block is linked to.
- When a library link is broken, the parameter "ReferenceBlock" is an empty array.
Part 2:
I misunderstood the issue. Once the libraries are loaded, they are on your MATLAB path and part of the workflow. Rehash doesn't remove items from the path, just cleans them up (you can check out the docs for what all goes on in the cleanup. Feel free to ask if you have specific questions).
I think what you are running into is the library blocks now being on your MATLAB path. The following outlines modifying the path and getting a list of all items on your path. https://www.mathworks.com/help/matlab/matlab_env/add-remove-or-reorder-folders-on-the-search-path.html
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!