Migrating from MATLAB
MathJet’s own interpreter is MATLAB-syntax compatible. Most existing
.m scripts run as-is. This guide covers what works out of the box,
what to watch for, and the equivalent workflow patterns when something
doesn’t translate directly.
The short version: open your .m file in MathJet, run it, and most
things just work. The rest of this document is for the situations where
they don’t.
Quick start
Section titled “Quick start”- In MathJet, File → Open (or drag-drop the file onto the window).
- Pick your
.mfile. It opens in MathJet’s editor. - Press Run (or
F5— check: keybinding). Variables populate the workspace; plots open as native MathJet figures.
That’s the whole flow for most cases. If your script ran in MATLAB and uses only base-language features (no Toolboxes, no Simulink, no MEX), it should run in MathJet.
What works out of the box
Section titled “What works out of the box”MathJet’s own interpreter implements the MATLAB language at the syntax level. The following are supported.
Language constructs
Section titled “Language constructs”- Matrix and vector literals (
[1 2 3; 4 5 6]) - Element-wise operators (
.*,./,.^,.') - Standard control flow (
if,elseif,else,for,while,switch,break,continue,return) - Function definitions in
.mfiles - Anonymous functions (
@(x) x.^2) - Function handles
- Cell arrays (
{1, 'two', [3 4]}) and cell indexing (c{i},c(i)) - Structs (
s.field = value) - Variable scoping (workspace, function, anonymous closure)
- String and char arrays
- Logical indexing (
x(x > 0)) - Colon expressions (
1:10,0:0.1:pi)
Common functions
Section titled “Common functions”A representative — not exhaustive — list:
- Creation:
zeros,ones,eye,linspace,logspace,rand,randn,magic - Inspection:
size,length,numel,ndims,class,isempty,isnumeric,ischar - Reshape and combine:
reshape,repmat,cat,vertcat,horzcat,permute,squeeze - Math:
sum,mean,median,std,var,min,max,sort,cumsum,prod,abs,sqrt,exp,log,sin,cos,tan, etc. - Linear algebra:
mldivide/\,mrdivide//,inv,pinv,eig,svd,qr,lu,det,rank,norm - Plotting:
plot,scatter,bar,hist,surf,mesh,contour,imshow,figure,subplot,xlabel,ylabel,title,legend,axis,hold - I/O:
fopen,fclose,fread,fwrite,fprintf,disp,error,warning
File formats
Section titled “File formats”.mscript and function files — open and run directly..matfiles — read support for the variables you’d expect (numeric arrays, cell arrays, structs, strings). Check: which.matversions; behavior for object handles, function handles inside.mat, MATLAB classes..xlsx— natively, including formulas, charts, and conditional formatting.xlsread/writematrixwork, but you can also just open the file as a spreadsheet in MathJet and edit it directly.
Common gotchas
Section titled “Common gotchas”Toolboxes are not included
Section titled “Toolboxes are not included”MathJet does not bundle the MATLAB Toolboxes (Statistics, Signal Processing, Image Processing, Optimization, Control Systems, etc.). If your script relies on Toolbox-specific functions, you’ll see one of three outcomes:
-
The function exists in MathJet’s base library. Some commonly-used Toolbox functions (
fftfrom Signal Processing, basic statistics) are in the base — your script runs. -
The function exists in a Python package.
scipy,statsmodels,scikit-learn,cvxpy, etc. cover a substantial fraction of Toolbox functionality. Call them via the polyglot formula bar or in a Python cell:% MATLAB (Signal Processing Toolbox):[b, a] = butter(4, 0.1);# MathJet — same operation, called from a Python cell:from scipy.signal import butterb, a = butter(4, 0.1) -
The function is genuinely Toolbox-bound. No
scipyequivalent, no MathJet base implementation. In that case, MathJet is a complement to your MATLAB+Toolboxes workflow, not a replacement — keep both, use MathJet where it shines.
Simulink is not supported
Section titled “Simulink is not supported”MathJet does not run Simulink models. For dynamical-systems work that depends on Simulink, MathJet is not a substitute. If your model produces data that you analyze afterward, MathJet is excellent for the analysis side — the simulation execution is what’s out of scope.
MEX files don’t run
Section titled “MEX files don’t run”MEX files (compiled C/C++ extensions linked against MATLAB’s API) are
MATLAB-internal. MathJet can’t load .mexw64 / .mexmaci64 /
.mexa64 binaries. If you have critical MEX-based code, the path forward
is:
- Call into the underlying C/C++ from Python via
ctypesorcffi, then call that Python from MathJet. - Or rebuild as a MathJet extension. (Reference page coming soon.)
Subtle differences in language edge cases
Section titled “Subtle differences in language edge cases”A handful of MATLAB language behaviors live in dark corners — operator
precedence with mixed types, output-argument unpacking with empty
matrices, certain eval-time quirks. MathJet’s interpreter targets the
documented MATLAB language. If your code depends on undocumented or
implementation-detail behavior, you may see differences.
If you hit one, the diagnostic flow is:
- Reproduce on a small example.
- Check the (forthcoming) MATLAB compatibility reference page for known divergences.
- If it’s not listed there, file a report at info@mathjet.com — we treat compatibility regressions as bugs.
Plot styling
Section titled “Plot styling”MathJet’s native figures use modern interactive rendering (axis folding,
data grouping, click-to-highlight). Plots produced by plot, scatter,
etc. work and look reasonable, but the exact visual styling — default
colormaps, grid style, legend formatting — may differ slightly from
MATLAB’s defaults. Most users find MathJet’s defaults more readable; if
you need pixel-identical output (for a report template, etc.), set
styling explicitly.
Equivalent workflows
Section titled “Equivalent workflows”| If you used to… | In MathJet… |
|---|---|
Run a .m script daily and look at plots | Open the .m directly. Plots become native interactive figures. |
xlsread('data.xlsx') to load spreadsheet data | Open the .xlsx natively as a spreadsheet, or use xlsread as before. The cells are already a first-class data source. |
save data.mat / load data.mat for workspace persistence | Use the same save / load, or save the whole MathJet session as a .mjw workspace file (preserves figures and layout too). |
Write a function in a .m file | Same — .m functions are first-class. |
| Use a Stats Toolbox function | Try the scipy.stats or statsmodels equivalent via Python interop. |
| Use Simulink | Keep Simulink for the model. Use MathJet for the analysis side. |
Share a static .png of a plot in a report | MathJet figures save as .png, but you can also share the .mjw workspace and the recipient sees the interactive figure. |
Glue MATLAB results into Excel via xlswrite | Skip the glue. The MathJet spreadsheet IS your Excel-compatible data view. |
Bridge from MATLAB to Python via pyrun | Skip the bridge. Both run in the same MathJet process; objects share memory. |
Beyond the migration: things MathJet does that MATLAB doesn’t
Section titled “Beyond the migration: things MathJet does that MATLAB doesn’t”Once your .m workflow is up and running in MathJet, the new
capabilities are worth exploring:
- Polyglot formula bar. Write Excel-style formulas, Python calls,
R calls, or
.mcalls in any cell. The same data backs all of them. - Live linking. Edit a cell, the plot redraws. Adjust a plot interactively (drag a point), the underlying data changes.
- Multi-language sessions. Pull a result through
numpy, hand it to R for a statistical test, format it in a spreadsheet — all in one session, all in shared memory. - Patented visualization features. Axis folding, interactive data grouping, graphical value editing, interactive graph filtering. Not available in any other tool.
- Native cross-platform performance. Same
.mjwworkspace on Windows, Linux, and macOS. Native binary speed everywhere. - No subscription. Free to download, free for academic use. Pro edition for commercial / team use coming soon.
What MathJet does not replace
Section titled “What MathJet does not replace”To repeat the honest note from the Coming from MATLAB page:
MathJet does not replace MATLAB Toolboxes (Statistics, Signal Processing, Image Processing, Optimization, etc.) or Simulink. For users whose work depends on those, MathJet is a complement, not a replacement.
If your work is genuinely Toolbox- or Simulink-bound, the right setup is MathJet alongside MATLAB: use MathJet for plotting, spreadsheet integration, multi-language analysis, and interactive exploration; keep MATLAB for the Toolbox / Simulink parts.
Getting help
Section titled “Getting help”- Compatibility bugs: info@mathjet.com.
- API and function specifics: see the reference docs.
- Why MathJet is built the way it is: see the overview.