How can I disable the compilation of a P-code file using the MATLAB Compiler 4.0 (R14)?

1 次查看(过去 30 天)
I am creating an application that I would like to distribute in P-code format. However, I would like to ensure that the people I distribute the P-coded file to are not able to compile and distribute this function.
In previous versions of the MATLAB Compiler, P-code files were not compilable. As of MATLAB Compiler 4.0 (R14), however, a function that calls a P-coded file can be compiled.

采纳的回答

MathWorks Support Team
In order to prevent P-code from running in stand-alone mode, you can implement one IF statement in the MATLAB code which is used to generate P-code. This method uses a call to the ISDEPLOYED function in order to determine if the code is running in a stand-alone application or within MATLAB.
Note that unlike prior versions of the MATLAB Compiler, C code is not generated, and proprietary information you wish to keep in the p-code file is maintained as proprietary. The prevention of compilation of P-code in the Compiler 4.0 does not apply as significantly as it did in prior versions of the Compiler. In prior versions, the main reason to prevent compilation of these files was to preserve intellectual property, but this is no longer necessary as it is still be encrypted as P-code format in a standalone application. The external pragma ("%#external") can be used to prevent a P-code file from being compiled:
function myPCodeFunction
%#external
desiredCode % Run the main portion of code
end
Again, although technically the P-code can be compiled to a standalone application, in this case it is kept both proprietary and disabled for deployment. It works because the external pramga tells the MCC compiler to use an external implementation of any MATLAB or P-file it appears in. When someone tries to build an application with the file, they will receive an error when the program tries to link the files together.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by