Run MATLAB code online, free, in your browser
CivilKit Calcs can run code written in the MATLAB language inside a calculation sheet. Open a .m file, or write a #matlab block, and it runs in the page: no install, no account, and nothing is sent to a server. It prints, draws its plots in the sheet, and passes chosen values to the calculation lines below it, with units.
It is not MATLAB. It is an independent implementation of the language that runs as WebAssembly in your browser, and it covers a large part of the core language and the numerical functions engineers use. This page says what it does and where it stops, so you can try a script before you rely on it.
Open this sheet in Calcs Open a blank sheet
Try it in a minute
Use Open this sheet in Calcs on this page for a worked beam example, or start from a blank sheet and write:
"Beam check
#matlab
L = 6; w = 12;
x = linspace(0, L, 61);
M = w*x.*(L - x)/2;
fprintf('Maximum moment %.2f kN m\n', max(M));
plot(x, M); xlabel('x (m)'); ylabel('M (kN m)'); grid on
% export: L, w
#end matlab
"The Calcpad lines after the block use what it exported
Mmax = w*L^2/8|kN*m
The block prints its result, draws the moment curve where the plot call is, and hands L and w to the lines after it. Those lines are ordinary calculation lines: they take units, appear in the report, and can be exported to Word, Excel or PDF.
Open a .m file you already have
Use File, Open, or drop a .m file on the page. A script opens as a worksheet holding its code in a block. A file that starts with function goes into the file library, and any block that calls that function uses it, along with the functions that one calls. If a function is missing the error names the file to add.
Data files stay with the worksheet
Add a CSV or text file to the library and read it by name: readmatrix('loads.csv'), readtable, fopen and fgetl, load and save for MAT files all work, and a file one block writes can be read by the next. Save with its files makes one .cpz file with the worksheet and its data, which opens here again with everything in place.
Plots
Line, scatter, bar, stairs, area, stem, error-bar and histogram plots, with legends, titles, labels, log axes and subplots, draw as pictures that print with the report. Surfaces, 3-D lines, images, contours and quiver plots are interactive charts you can rotate and zoom. Polar plots, filled patches and regions are not drawn yet.
What it does not do
- It is not MATLAB, and results are not guaranteed identical in every case. The engine is tested against self-checking programs (linear algebra, differential equations, FFT, strings, cells and structures, plots, file input and output); check what you will rely on.
- No
classdefobjects, no 64-bit integers beyond 253, nomatfile,fminuncordel2, no apps or interactive figures, and no toolboxes beyond the core language and a large part of the numerical functions. - Loops run at interpreter speed in the browser, noticeably slower than desktop MATLAB; vectorised code is much closer. A block that runs over 20 seconds is stopped, and the page offers 120.
MATLAB is a trademark of The MathWorks, Inc. CivilKit Calcs is not made by, affiliated with or endorsed by The MathWorks. The name is used here only to say which language the code is written in.
Questions
Is this MATLAB?
No. It runs MATLAB-language code on an independent engine that is not made by or connected to The MathWorks. Most core-language scripts run; some features are missing, listed on this page.
Is my code uploaded anywhere?
No. The engine is compiled to WebAssembly and runs in your browser. The code and data stay on your machine.
Does it need a licence or an account?
No. There is nothing to install or sign in to.
Can I run a whole project with several files?
Yes. Function files in the library are found by the blocks that call them, and data files are read by name. Save with its files writes the lot as one .cpz.
Can I get my code back out?
Yes. Save as MATLAB project writes a zip with the script, its function and data files and a report, which runs in MATLAB or Octave. See the page on MATLAB homework and .m files.