Runs Matlab code in typescript/javascript
This package acts as a middle man between node.js and Matlab. You can interact with Matlab through a Session
, which is simply a wrapper around Matlab's REPL
Before using matlab-bridge
, you should have jsonlab installed as a Matlab toolbox. You can download the latest release from jsonlab's release page.
Add matlab-bridge
to your node.js project.
yarn add matlab-bridge
Creating a Session
const session = new MatlabSession();
await session.initialize();
Evaluating a block of code
const output = await session.evaluateScript(`
a = linspace(1, 5, 5)';
b = a .* 2;
result.a = a;
result.b = b;
jsonencode(result)
`);
Get the whole workspace
const workspace = await session.getWorkspace();