RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • addpath
    • cd
    • copyfile
    • delete
    • dir
    • exist
    • fileattrib
    • fileparts
    • fullfile
    • genpath
    • getenv
    • getpref
    • isenv
    • isfile
    • isfolder
    • ispref
    • ls
    • matlabroot
    • memmapfile
    • mkdir
    • movefile
    • open
    • opentoline
    • path
    • pathsep
    • pcode
    • pwd
    • readstruct
    • rehash
    • restoredefaultpath
    • rmdir
    • rmpath
    • run
    • savepath
    • setenv
    • setpref
    • system
    • tempdir
    • tempname
    • uigetdir
    • uigetfile
    • uiputfile
    • unsetenv
    • userpath
    • what
    • winqueryreg
    • xmlread
    • xmlwrite

pcode — Generate RunMat-executable content-obscured P-code files from MATLAB source.

pcode reads MATLAB .m source files and writes RunMat-generated .p files that obscure the source text while remaining executable by RunMat. RunMat does not implement MathWorks' proprietary P-code file format; non-RunMat .p files are rejected with a deterministic invalid-P-code error.

Syntax

pcode(item)
pcode(item, version)
pcode(item1, item2, ..., itemN, "-inplace")

Inputs

NameTypeRequiredDefaultDescription
itemStringScalarYes—MATLAB source file, source name, folder, or wildcard pattern to encode.
versionStringScalarNo-R2007bObfuscation compatibility selector, either -R2007b or -R2022a.
item1StringScalarYes—First MATLAB source file, source name, folder, or wildcard pattern.
itemNStringScalarVariadic—Additional source files, source names, folders, or wildcard patterns.
inplaceStringScalarNo—Use -inplace to write each P-code file beside its source file.

Errors

IdentifierWhenMessage
RunMat:pcode:NotEnoughInputsNo source item is provided.pcode: not enough input arguments
RunMat:pcode:TooManyOutputs`pcode` is called with requested output arguments.pcode: too many output arguments
RunMat:pcode:InvalidArgumentAn argument is not a character row, string scalar, or scalar string array.pcode: arguments must be character vectors or string scalars
RunMat:pcode:EmptyItemA source item is empty.pcode: source item must not be empty
RunMat:pcode:InvalidOptionAn option is not -inplace, -R2007b, or -R2022a.pcode: invalid option
RunMat:pcode:PathResolveFailedRunMat cannot resolve a source item or destination path.pcode: failed to resolve path
RunMat:pcode:FileNotFoundNo MATLAB `.m` source file matches the item.pcode: source file not found
RunMat:pcode:UnsupportedExtensionThe source item names an unsupported file type, including `.mlx` live scripts.pcode: only MATLAB .m source files are supported
RunMat:pcode:FileReadFailedA source file cannot be read as text.pcode: failed to read source file
RunMat:pcode:FileWriteFailedThe destination `.p` file cannot be written.pcode: failed to write P-code file
RunMat:pcode:InvalidPcodeA `.p` file is not a RunMat-generated P-code container or fails integrity checks.pcode: invalid or unsupported P-code file

How pcode works

  • pcode(item) accepts a source name, .m path, folder, or wildcard pattern and writes .p files in the current folder.
  • When item names a folder, RunMat encodes the .m files directly in that folder. Folder processing is nonrecursive, matching the common MATLAB pcode(folder) behavior.
  • pcode(item, '-inplace') writes each generated .p beside its source .m file.
  • pcode(item, '-R2007b') and pcode(item, '-R2022a') select RunMat's compatibility-labeled obfuscation algorithms. The default is -R2007b.
  • Multiple items are accepted in one call, including command syntax such as pcode src/*.m -R2022a -inplace.
  • Wildcard items only encode matching .m files and ignore non-source files.
  • When source files live in package or class folders, non-inplace output preserves the trailing +package and @class folder structure under the current folder.
  • pcode has no outputs. Requesting output arguments raises RunMat:pcode:TooManyOutputs.
  • Live scripts (.mlx) and non-.m source files are not supported and raise RunMat:pcode:UnsupportedExtension.

Does RunMat run pcode on the GPU?

pcode is a host filesystem/source-packaging operation and is not eligible for provider-native execution or fusion.

Examples

Create P-code in the current folder

pcode worker
run worker

Write P-code beside the source file

pcode src/worker.m -inplace

Encoding multiple files

pcode src/*.m helpers/*.m -R2022a

Using pcode with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how pcode changes the result.

Run a small pcode example, explain the result, then change one input and compare the output.

FAQ

Can RunMat execute .p files generated by MATLAB?⌄

No. MATLAB P-code is proprietary and undocumented. RunMat executes .p files generated by RunMat and reports an invalid/unsupported P-code error for other .p contents.

Does P-code provide cryptographic secrecy?⌄

No. RunMat's P-code is content-obscured source packaging for compatibility workflows, not a cryptographic protection or licensing boundary.

Does run prefer P-code over source?⌄

Yes. For bare script names and source-path inputs without an extension, RunMat resolves .p before .m and decodes RunMat-generated P-code before execution.

Related Io functions

Repl Fs

addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · mkdir · movefile · open · opentoline · path · pathsep · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite

Net

accept · read · readline · tcpclient · tcpserver · write

Tabular

arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format · input

Filetext

fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how pcode is executed, line by line, in Rust.

  • View the source for pcode in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Errors
  • How pcode works
  • Does RunMat run pcode on the GPU?
  • Examples
  • Create P-code in the current folder
  • Write P-code beside the source file
  • Encoding multiple files
  • Using pcode with coding agents
  • FAQ
  • Related Io functions
  • Repl Fs
  • Net
  • Tabular
  • Audio
  • Io
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Open-source implementation
  • About RunMat