Skip to content

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.

  1. In MathJet, File → Open (or drag-drop the file onto the window).
  2. Pick your .m file. It opens in MathJet’s editor.
  3. Press Run (or F5check: 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.

MathJet’s own interpreter implements the MATLAB language at the syntax level. The following are supported.

  • 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 .m files
  • 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)

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
  • .m script and function files — open and run directly.
  • .mat files — read support for the variables you’d expect (numeric arrays, cell arrays, structs, strings). Check: which .mat versions; behavior for object handles, function handles inside .mat, MATLAB classes.
  • .xlsx — natively, including formulas, charts, and conditional formatting. xlsread / writematrix work, but you can also just open the file as a spreadsheet in MathJet and edit it directly.

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:

  1. The function exists in MathJet’s base library. Some commonly-used Toolbox functions (fft from Signal Processing, basic statistics) are in the base — your script runs.

  2. 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 butter
    b, a = butter(4, 0.1)
  3. The function is genuinely Toolbox-bound. No scipy equivalent, 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.

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 (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:

  1. Call into the underlying C/C++ from Python via ctypes or cffi, then call that Python from MathJet.
  2. Or rebuild as a MathJet extension. (Reference page coming soon.)

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:

  1. Reproduce on a small example.
  2. Check the (forthcoming) MATLAB compatibility reference page for known divergences.
  3. If it’s not listed there, file a report at info@mathjet.com — we treat compatibility regressions as bugs.

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.

If you used to…In MathJet…
Run a .m script daily and look at plotsOpen the .m directly. Plots become native interactive figures.
xlsread('data.xlsx') to load spreadsheet dataOpen 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 persistenceUse 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 fileSame — .m functions are first-class.
Use a Stats Toolbox functionTry the scipy.stats or statsmodels equivalent via Python interop.
Use SimulinkKeep Simulink for the model. Use MathJet for the analysis side.
Share a static .png of a plot in a reportMathJet 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 xlswriteSkip the glue. The MathJet spreadsheet IS your Excel-compatible data view.
Bridge from MATLAB to Python via pyrunSkip 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 .m calls 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 .mjw workspace 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.

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.