File Exchange

image thumbnail

GenerateJavaScriptU​singMATLABCoder

version 1.0.6 (833 KB) by Geoff McVittie
Create JavaScript/WebAssembly functions from MATLAB functions using MATLAB Coder.

39 Downloads

Updated 12 Sep 2019

View License

Generate JavaScript using MATLAB Coder Add-On in combination with the Emscripten compiler converts your MATLAB functions into high-performance JavaScript/WebAssembly code. Generated code can be compiled, embedded, and run in any modern browser; including, Google Chrome, Mozilla FireFox, Microsoft Edge, and Apple Safari. The generated code can also be run in standalone JavaScript engines, such as NodeJS.

Cite As

Geoff McVittie (2019). GenerateJavaScriptUsingMATLABCoder (https://www.mathworks.com/matlabcentral/fileexchange/69973-generatejavascriptusingmatlabcoder), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

@JongWeiChew
Hello,
An updated version of the Add-On is underdevelopment that will provide easy settings of the configuration flags, including the compiler optimizations. As a work around, you can use the MATLAB coder app. In the configurations, select the "Emscripten" toolchain. You can then set and add additional compilation flags and arguments; including the compiler optimizations. Please feel free to reach out to me though the email contact information provided in the installed Add-On if you need any further help.
Thank you,
Geoff McVittie

@LeeHwayoung
Hello,
My initial guess is that the emscripten binaries need to be recompiled for your host computer architecture AMD64, see https://emscripten.org/docs/building_from_source/index.html. Please feel free to reach out to me though the email contact information provided in the installed Add-On for help with this process.
Thank you,
Geoff McVittie

Hi there, please advice - is it possible to make changes to the compilation flags used by Emscripten using this add-on?

c:\Users\lee\Desktop\emsdk>emsdk install latest
Warning: unknown machine architecture AMD64

Error: No tool or SDK found by name 'sdk-releases-fastcomp-7b4b328af02eafbc857b8ca1e3d9b12dddc56ef7-64bit'.

Could you please advise

⚠ For Add-On version 1.0.3 and before, on Windows, install the archived emsdk-1.12.0-full-64bit from the archived releases at the bottom of the downloads page, https://emscripten.org/docs/getting_started/downloads.html, instead of the git installation.

@Zachery Zhu
Hello,
Can you provide more detail on the problem you had with the installation?
On Windows 10, the steps should be almost exactly as follows:

1. In Windows 10, install Emscripten
C:\Users\<user>\Desktop> git clone https://github.com/emscripten-core/emsdk.git
C:\Users\<user>\Desktop> cd emsdk
C:\Users\<user>\Desktop> emsdk install latest
C:\Users\<user>\Desktop> emsdk activate latest

2. In MATLAB, install the "GenerateJavaScriptU​singMATLABCoder" using the Add-Ons Manager.

3. In MATLAB, open the Setup.mlx by running:
>> webcoder.setup.start()

4. Follow steps 3 to 6 in Setup.mlx

Please reach out if any of the above does not work. Please include any error message that is thrown.

Thank you,
Geoff

Zachery Zhu

I still couldn't install it correctly, haha. I'm using windows 10

@Supannee Learkthanakhachon
Thank you for the feedback. An update, v1.0.3, has corrected the typos in the examples.
Can you provide more information on the specific issues experienced in installation process? I would like to better understand and, in the future, potentially correct these issues.

Please fix the typo in the example
>> server = webcoder.utilities.DeploymentServer("Port",8000)
it should be
>>server = webcoder.utilities.DevelopmentServer("Port",8000)
I spent a long time to figure this out. Plus...the entire installation process was a headache.

On Mac OSX, emscripten setup is done with bash scripts, so webcoder.setup.verifyThirdPartyTools failed with an error "BASH_SOURCE Undefined variable". You'll want to set MATLAB's shell to bash using something like: export MATLAB_SHELL=`which bash` before you verify.

Updates

1.0.6

Fix to the missing Toolchain issue.

1.0.5

Fixed issue that limited function name size.

1.0.4

Installation updated to support the Fastcomp update to Emscripten SDK.

1.0.3

Added checks on setup and fix typos in examples.

1.0.2

Update to title to add spaces for improved web search

1.0.1

Fix to icon.

MATLAB Release Compatibility
Created with R2018b
Compatible with R2018b to any release
Platform Compatibility
Windows macOS Linux

doc

examples/helloBrowser

examples/passingData