Main Content

sscprotect

Generate Simscape protected files from source files

Since R2024b

Description

sscprotect(filename) generates a Simscape™ protected file, named filename.sscp, from the Simscape source file named filename.ssc, and places the protected file in your current working folder. filename can include absolute path to the file, or relative path if the file is in a subfolder of the current working folder. If this path includes namespace folders, the namespace structure will be recreated under the current working folder (unless it already exists) and the protected file placed in that namespace. The extension .ssc in filename is optional.

The sscprotect command creates content-obscured files (Simscape protected files) from Simscape source files, to enable model sharing without disclosing the component or domain source. While Simscape source files have the extension .ssc, Simscape protected files have the extension .sscp.

example

sscprotect(filename -inplace) generates a Simscape protected file, named filename.sscp, from the Simscape source file named filename.ssc, and places the protected file in the same folder as the source file.

example

sscprotect(dirname) generates Simscape protected files from all the Simscape source files in the folder named dirname, and places the protected files under your current working folder. If the path to dirname includes namespace folders, the namespace structure will be recreated under the current working folder (unless it already exists) and the protected files placed in the namespace, similar to when protecting a single file.

example

sscprotect(dirname -inplace) generates Simscape protected files from all the Simscape source files in the folder named dirname, and places the protected files in the same folder as the source files.

Note

Existing Simscape protected files are overwritten without warning.

Simscape protected files have higher precedence than the source files when you build a library. If the protected and the source files are in the same folder, and protected files are out of date, sscbuild will use the protected files to build the library, but you will get a warning.

example

Examples

collapse all

To protect a single file, with the protected file placed under your current working folder, at the MATLAB® Command prompt, type:

sscprotect C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements\my_spring.ssc

This command creates a folder called +SimscapeLibrary and a subfolder called +MechanicalElements in your current working folder (unless these folders already exist) and generates a file called my_spring.sscp in the +MechanicalElements folder.

To protect a single file, with the protected file placed in the same folder as the source file, type:

sscprotect C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements\my_spring.ssc -inplace

This command generates a file called my_spring.sscp in the C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements folder.

To protect all files in a folder, with the protected files placed under your current working folder, type:

sscprotect C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements

This command generates protected files for each source file in the C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements folder, and places the protected files in a folder called +SimscapeLibrary\+MechanicalElements in your current working folder (creating this folder structure, if it does not exist).

To protect all files in a folder, with the protected files placed in the same folder as the source files, type:

sscprotect C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements -inplace

This command generates protected files for each source file in the C:\Work\libraries\source\+SimscapeLibrary\+MechanicalElements folder, and places the protected files in the same folder.

Input Arguments

collapse all

Name of a Simscape file, specified as a character vector or a string scalar. The extension .ssc is optional. filename can include absolute path to the file, or relative path if the file is in a subfolder of the current working folder. If this path includes namespace folders, the namespace structure will be recreated under the current working folder (unless it already exists) and the protected file placed in the namespace

When you call sscprotect using the command syntax, do not use quotes around filename. For more information on the command-function duality, see Choose Command Syntax or Function Syntax.

Example: sscprotect MyFile is the command syntax to generate a protected file, MyFile.sscp, from the file MyFile.ssc. The equivalent function syntax is sscprotect('MyFile').

Name and location of the folder containing Simscape files, specified as a character vector or a string scalar.

When you call sscprotect using the function syntax, you can also use MATLAB variables and functions, such as fullfile or genpath, to specify the path to the folder.

Example: fullfile(tempdir,'MyLibrary.slx') with function syntax, you can use MATLAB variables and functions to specify the path.

Version History

Introduced in R2024b