| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
pcode fun
pcode *.m
pcode fun1 fun2 ...
pcode... -inplace
pcode fun obfuscates (i.e., shrouds) 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.
If the input file resides within a package and/or class directory, then the same package and class directories are applied to the output file. See example 2, below.
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.
See Creating P-Code Files in the MATLAB Programming Fundamentals documentation for more information.
Convert selected M-files from the sparfun directory into pcode files:
dir([matlabroot '\toolbox\matlab\sparfun\spr*.m']) . .. sprand.m sprandn.m sprandsym.m sprank.m cd C:\work\pcodetest pcode([matlabroot '\toolbox\matlab\sparfun\spr*.m']) dir C:\work\pcodetest . sprand.m sprandn.m sprandsym.m sprank.m .. sprand.p sprandn.p sprandsym.p sprank.p
This example takes an input file that is part of a package and class, and generates a pcode file for it in a separate directory. M-file test.m resides in the following package and class directory:
C:\work\+mypkg\@char\test.m
Set your current working directory to empty directory math\pcodetest. This is where you will generate the pcode file. This directory has no package or class structure associated with it at this time:
cd C:\math\pcodetest dir . ..
Generate pcode for test.m. Because the input file is part of a package and class, MATLAB creates directories +mypkg and @char so that the output file belongs to the same:
pcode C:\work\+mypkg\@char\test.m
dir('C:\math\pcodetest\+mypkg\@char')
. .. test.pWhen you generate a pcode file inplace, MATLAB writes the output file to the same directory as the input file:
pcode C:\work\+mypkg\@char\test.m -inplace dir C:\work\+mypkg\@char . .. test.m test.p
![]() | pchip | pcolor | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |