This is because when executing 'ssc_build' on a package, some derived files are generated in a subfolder called 'sscprj', which are subsequently used to facilitate the generation of Simulink library files (i.e. the 'package_lib.slx' files). More specifically, the derived files are used for dialog infrastructures in Simulink. Because such technology could change from one release to another, we recommend to rebuild the custom library in any different release to ensure reliability.
A possible workaround is to provide a script to the user of these custom Simscape libraries. The script can compare the user's MATLAB/Simulink version with the version in which the provided library files are generated. If there is a mismatch, it can automatically clean and rebuild the library to make it compatible with the user's current version. Please find the code snippet below which illustrates the workflow on a custom package 'MyCapacitors':
pkg = 'MyCapacitors';
lib = [pkg '_lib.slx'];
v_matlab = ['R' version('-release')];
info = Simulink.MDLInfo(lib);
v_lib = info.ReleaseName;
if ~strcmpi(v_matlab, v_lib)
ssc_clean(pkg);
ssc_build(pkg);
end
If multiple packages are provided to the users, you may also consider placing all the package names in a data structure (e.g. cell array), and use a for-loop to traverse through all the elements and perform the clean and rebuild.
Best Answer