MATLAB: Dynamically change simulink library path

2018librarysimulink

Hello,
without changing the Simulink model I'd like to switch between two source libraries for the blocks the model contains.
E.g. there is an old Simulink lib stored in folder A and a new Simulink lib – with the same name – in folder B. Now I'd like to control which one is taken by the model.
First I simply changed the search path – including folder A and removing the unwanted path B. This worked in principle but Simulink somehow remembers path B and still uses that one.
Is there a way to unload/refresh Simulink lib associations? Any other idea how to realize something like this?
Many thanks in advance
Timo

Best Answer

Hello,
many thanks for your efforts. Meanwhile I found a workaround which does the job. It points to the direction Fangjun proposed:
close_system('MyLib.slx')
rmpath('LibPath_A')
addpath('LibPath_B')
load_system('MyLib.slx')
The advantage is that you do not have to close/open the Simulink model. The blocks are updated after a couple of seconds automatically - at least by saving the model or descending a block.
Again, thanks to all of you for your feedback. best regards Timo