Friday, 6 December 2013

How to convert .m file to .p file?

.p file stands for protected file. Matlab provides us one facility i.e. conversion from .m to .p file. We can convert important functions from .m to protected files. Matlab has a standard encryption key using that key Matlab will convert .m to .p file. If we open that file with the help of notepad or WordPad then we can’t get anything from that file.

pcode fun
pcode *.m
pcode fun1 fun2 ...
pcode... –inplace


pcode fun: M-file fun.m for the purpose of protecting its proprietary source code. The encrypted M-code is written to P-file fun.p in the current directory. The original M-file can be anywhere on the search path.

pcode *.m: creates P-files for all the M-files in the current directory.

pcode fun1 fun2 ... :creates P-files for the listed functions.

pcode... -inplace: creates P-files in the same directory as the M-files. An error occurs if the files cannot be created.

1. You can save a prepared version of a function or script, called P-code files, for later MATLAB sessions using the pcode function. For example,
>> pcode dist
2. parses dist.m and saves the resulting pseudocode to the file named dist.p. This saves MATLAB from reparsing dist.m the first time you call it in each session.
3. MATLAB is very fast at parsing so the pcode function rarely makes much of a speed difference.
4. One situation where pcode does provide a speed benefit is for large GUI applications. In this case, many M-files must be parsed before the application becomes visible.
5. You can also use pcode to hide algorithms you have created in your M-file, if you need to do this for proprietary reasons. 

Following figure shows you pcode file of the respective function ADD

No comments:

Post a Comment