Matlab P File



If item is a.m file, then the resulting file is item.p. If item is a folder, then all script or function files in that folder are obfuscated in the current folder. A P-file takes precedence over the corresponding.m file for execution, even after modifications to the.m file. Matlab.p files Hi everyone, I am taking a 'Matlab for engineers' class and I have been using Octave instead so for with great results. Thanks for the good work. The only time I have to go into Matlab ( a friends comp or library) is when the Professor gives us a.p file so that we can test our functions. Now I just check the code as a script.

  1. What Is Matlab P Code
  2. Matlab.p Files

Protect Your Source Code

Open

Although MATLAB® source code (.m) is executable by itself, the contents of MATLAB source files are easily accessed, revealing design and implementation details. If you do not want to distribute your proprietary application code in this format, you can use one of these options instead:

  • Deploy as P-code — Convert some or all of your source code files to a content-obscured form called a P-code file (from its .p file extension), and distribute your application code in this format. When MATLAB P-codes a file, the file is obfuscated not encrypted. While the content in a .p file is difficult to understand, it should not be considered secure. It is not recommended that you P-code files to protect your intellectual property.

    MATLAB does not support converting live scripts or live functions to P-code files.

  • Compile into binary format — Compile your source code files using the MATLAB Compiler to produce a standalone application. Distribute the latter to end users of your application.

Building a Content Obscured Format with P-Code

A P-code file behaves the same as the MATLAB source from which it was produced. The P-code file also runs at the same speed as the source file. P-code files are purposely obfuscated. They are not encrypted. While the content in a .p file is difficult to understand, it should not be considered secure. It is not recommended that you P-code files to protect your intellectual property.

Note

Because users of P-code files cannot view the MATLAB code, consider providing diagnostics to enable a user to proceed in the event of an error.

Building the P-Code File

To generate a P-code file, enter the following command in the MATLAB Command Window:

The command produces the files, file1.p, file2.p, and so on. To convert all.m source files residing in your current folder to P-code files, use the command:

See the pcode function reference page for a description of all syntaxes for generating P-code files.

Invoking the P-Code File

Matlab P File

You invoke the resulting P-code file in the same way you invoke the MATLAB .m source file from which it was derived. For example, to invoke file myfun.p, type

To invoke script myscript.p, type

File

When you call a P-code file, MATLAB gives it execution precedence over its corresponding .m source file. This is true even if you happen to change the source code at some point after generating the P-code file. Remember to remove the .m source file before distributing your code.

Running Older P-Code Files on Later Versions of MATLAB

P-code files are designed to be independent of the release under which they were created and the release in which they are used (backward and forward compatibility). New and deprecated MATLAB features can be a problem, but it is the same problem that would exist if you used the original MATLAB input file. To fix errors of this kind in a P-code file, fix the corresponding MATLAB input file and create a new P-code file.

P-code files built using MATLAB Version 7.4 and earlier have a different format than those built with more recent versions of MATLAB. These older P-code files do not run in MATLAB 8.6 (R2015b) or later. Rebuild any P-code files that were built with MATLAB 7.4 or earlier using a more recent version of MATLAB, and then redistribute them as necessary.

Building a Standalone Executable

What Is Matlab P Code

Another way to protect your source code is to build it into a standalone executable and distribute the executable, along with any other necessary files, to external customers. You must have the MATLAB Compiler™ and a supported C or C++ compiler installed to prepare files for deployment. The end user, however, does not need MATLAB.

To build a standalone application for your MATLAB application, develop and debug your application following the usual procedure for MATLAB program files. Then, generate the executable file or files following the instructions in Create Standalone Application from MATLAB (MATLAB Compiler).

Matlab.p Files

On Wed, May 25, 2016 at 18:44:53 +0200, Julien Bect wrote:
> Actually, I'm not sure at all about the correct answer to this question. I
> would like to hear from Octave's core developers about that.
I suspect you may get as many different opinions as there are
developers.
Personally, I think the main motivation for Octave to support Matlab's
syntax at all is to allow users to move their interpreted source code
(in m-file form) from Matlab to the better, free Octave environment,
thereby increasing the 'value' of the code.
IMHO, supporting obfuscated Matlab executable files does little to
increase the value of the code. The p-file is still a black box, users
do not have the freedom to study or improve the code.
Even if it works in one version of Octave, there is no guarantee that it
will work in a future version of Octave — not only because the
obfuscation format may change, but because some unrelated behavior may
change and we have no insight into what expressions are actually being
evaluated.
If someone were to ask me whether they can run p-files in Octave, I
would ask why they don't have access to the original m-files. It's
possible there is a legal issue in tandem with the technical issue.
Cheers,
--
mike