MathLab help
Introduction
MathLab is a MATLAB-style lab that runs entirely in your browser. You write code, it plots, animates, plays sound, reads data and exports figures for papers — and any figure can be shared as a link or embedded on another website.
Your first script
Open MathLab, type this in the editor and press Run (or Ctrl/⌘ + Enter). Every code block in this help has a Try it button that opens it in the editor; the figure underneath is the live result.
x = linspace(0, 4*pi, 400);
plot(x, sin(x) .* exp(-x/6), 'LineWidth', 2)
title('A damped oscillation'), xlabel('x'), grid onTry it ↗What's in the window
- Editor — syntax colours, suggestions as you type (
Ctrl + Spacefor more), hints for the arguments of the function you are calling, and problems underlined before you run. - Figure — plots in 2D and 3D (drag to rotate, scroll to zoom, double-click to reset). Animations get a play bar; sound gets a player.
- Console — the results of lines without a semicolon, and a prompt for quick commands such as
help plot. - Problems, Workspace, Debug, Files — the issues found in your code, your variables, the step-by-step debugger, and data files you imported.
Where to go next
- The languageVectors, matrices, indexing, loops, functions, text, cells, structs, complex numbers and errors.Guide
- Figures, sound & dataPlot types, styles for papers and slides, export, animation, sound and importing data.Guide
- Tutorials12 step-by-step lessons, each step a live example.12 tutorials
- Function referenceEvery built-in function with its signature, a description and an example.508 functions
- Example galleryFrom physics and signal processing to finance, economics and live world data.111 examples
Sharing and embedding
Share / embed gives you a link to your script and an <iframe> for other websites. The script travels inside the link itself — nothing is stored on a server. Embedded figures stay live: animations play, 3D plots rotate and sounds can be played.
How MathLab differs from MATLAB
Most everyday MATLAB code runs unchanged, but MathLab is smaller:
- Arrays are numbers, text, logical values, complex numbers, cell arrays and structs (no 3-D arrays, tables, classes or integer types). A table from
readtableis a struct of columns, soT.Yearworks as in MATLAB. - Instead of
pauseanddrawnowloops, animations useanimate(seconds)and the time variablet. - Files live in your browser (Import data); web data is fetched before the script runs, so write addresses as text in the script.
- A few extras are MathLab-only:
animate,stylepresets for papers,spectrumandfrontier.