How do I specify the name of a protected simulink model (.slxp file)?

3 views (last 30 days)
I am using the Simulink.ModelReference.protect command to generate a protected model (.slxp) from a simulink model (.slx). For example, with file test_model.slx:
Simulink.ModelReference.protect("test_model");
 This will create a protected model "test_model.slxp". 
However, I want to name the .slxp file something different that the original .slx file for organizational purposes and to avoid shadowing conflicts. However, this is not possible according to the Simulink.ModelReference.protect documentation:
"The protected model has the same name as the source model and an .slxp file extension"
Trying to rename the .slxp either manually on the Files pane or using the "movefile" command will render the renamed .slxp file unusable. See command and image below:
movefile test_model.slxp renamed_slxp_file.slxp
Is there any way to specify the name of a .slxp file?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Nov 2025 at 0:00
While renaming .slxp files is not directly supported, here is a workaround to specify the name of a .slxp file:
  1. Rename the .slx file of interest
  2. Generate the .slxp file
  3. Rename the .slx file back to its original name
For example:
movefile test_model.slx renamed_slxp_file.slx
Simulink.ModelReference.protect("renamed_slxp_file")
movefile renamed_slxp_file.slx test_model.slx
The resulting "renamed_slxp_file.slxp" file will be usable as normal. You can even delete the test_model.slx file without issue.

More Answers (0)

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!