本周的文件交换选择

我们最好的用户提交

在Web应用程序中执行MATLAB算法

格雷格本周选择是Generate JavaScript Using MATLAB Coder经过杰夫麦维特

You are building a game where you want to model Einsteinian relativistic physics as part of an online learning tool. The interface is designed in HTML, CSS, and Javascript, but you prototyped the computational algorithms in MATLAB.

您知道您可以从MATLAB生成C代码....但是您无法将其部署为Web应用程序的一部分,因为它不会在Web浏览器中运行。

您是否必须在JavaScript中重写整个算法?或运行计算算法作为远程服务?

进入Emscripten,将C / C ++代码编译为的Transpilerwebassembly.使用JavaScript接口。

Geoff took this one step further, and created a code generation target for MATLAB Coder that automates the process of converting the algorithm to C-code, compiling it to Web Assembly, and creating the Javascript interface.

Why Not Just Write it in Javascript in the First Place?

这是一个公平的问题。从技术上讲,没有什么可以阻止你这样做。

我认为更容易创建,管理和处理Matlab中的数据和方程数组。所以写算法可能更简单。

但是,数据合成是我发现最有价值的部分。为了测试我们的算法和想法,可以很容易地合成MATLAB中的数据。我可以非常轻松地创建不同的合成数据集,从不同文件导入数据,并创建令人兴奋的MATLAB算法的测试用例。

当我不得不这样做在ot出于各种原因her languages like C, C#, and Javascript, I find myself struggling to generate suites of input data, and quickly being able to assess the results. My favorite debugging tool in MATLAB is阴谋,在那里我可以快速查看我的数据作为图表,以了解我的算法是如何表现的。

创建数据集所需的功能,阅读数据文件或者需要在这些其他较低级别的语言中创建审查输出结果,这使得测试复杂的计算算法棘手。

A Exemplar File Exchange Submission

Geoff已创建一个包含:

  • 文件
  • 例子
  • 易于设置说明

此外,他还添加了一些功能,使您可以针对在Web应用程序中找到的不同类型的代码入口点,如鼠标事件回调。

他还包括某些功能,使得代码部署到浏览器后,可以启用基本调试,例如能够在Web浏览器的Developer控制台中打印消息。

What do you think?

让我们知道here

|
  • 打印
  • 发送电子邮件

댓글

댓글을남기려면링크를클릭하여mathworks계정계정에로그인하거나하거나을새로새로새로