在JavaScript中调用MATLAB [英] Calling MATLAB in JavaScript

查看:178
本文介绍了在JavaScript中调用MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript的新手,正在使用JavaScript编写一个简单的网页游戏,以进行研究.人们可以玩游戏,并且将收集一些数据.收集的数据需要由MATLAB处理,并将结果返回给JavaScript代码.JavaScript代码将在客户端运行,而MATLAB将在服务器端运行.

I'm new to JavaScript and is coding a simple webpage game using JavaScript for my research. People can play the game and some data will be collected. The collected data needs to be processed by MATLAB and the results will be returned to the JavaScript code. The JavaScript code will be run on client-side and the MATLAB will be in server-side.

JavaScript程序如何在MATLAB中调用函数并从MATLAB接收数据?我在线搜索,发现MATLAB可以用作自动化服务器,然后由Web应用程序调用(

How can a JavaScript program call functions in MATLAB and also receive the data from MATLAB? I searched online and found that MATLAB can be used as an Automation server and then be called by web applications (http://www.mathworks.com/help/matlab/matlab_external/call-matlab-functions-from-a-web-application.html).

该链接给出了一个使用VBScript调用MATLAB文件的示例.但是,我找不到使用JavaScript进行调用的任何资源.我应该如何处理JavaScript?此外,JavaScript是否可以与MATLAB交互?

The link gives an example using VBScript to call MATLAB files. However, I cannot find any resource for using JavaScript to call. What should I do with JavaScript? Besides, is there a way that JavaScript can interact with MATLAB?

推荐答案

您的问题有些含糊.它是一个Web应用程序,因此涉及两个方面,即服务器端和客户端.是否需要在服务器端或客户端调用MATLAB?

Your question is somewhat vague. It is a Web app, so there are two parties involved, the server side and the client side. Does MATLAB need to be called at the server side or the client side?

假设它在服务器端,有多个选项

Assuming it is server side, there are multiple options

1)您提到的COM自动化服务器仅在运行Windows的服务器上有效,因为COM仅用于Windows.

1) The COM automation server you mentioned works only if the server is running Windows, because COM is for Windows only.

2)例如以某种方式(例如,使用CGI)将服务器端代码与C/C ++接口,并使用C/C ++代码调用

2) Interface the server side code with C/C++ somehow, for example, using CGI, and use the C/C++ code to invoke the MATLAB Engine.

3)使用MATLAB Builder JA将MATLAB代码转换为JAR文件,可以从基于Java的Web应用程序中调用该文件.同样,您可以使用MATLAB Builder EX将MATLAB代码转换为.NET程序集DLL,可以从基于C#(ASP.NET)的Web应用程序中调用它.

3) Use MATLAB Builder JA to convert MATLAB code to a JAR file, which can be invoked from your Java-based web app. Similarly, you can use MATLAB Builder EX to convert MATLAB code to a .NET assembly DLL, which can be invoked from your C# based (ASP.NET) web app.

4)设置一个MATLAB Production Server(MPS)并使用MATLAB Compiler部署代码.可以使用在服务器端Web应用程序中运行的Java,Python或.NET客户端代码来调用已部署的MATLAB代码.

4) Set up an MATLAB Production Server (MPS) and deploy code using MATLAB Compiler. The deployed MATLAB code can be invoked using Java, Python or .NET client code that run inside your server-side web app.

如果是客户端JavaScript与MATLAB对话,恐怕没有简单的方法可以使两者直接对话.MPS仍然是可能的,但是它将通过服务器端Web应用程序进行.也许您可以探索使用MATLAB Coder将MATLAB代码转换为C代码,然后使用诸如transpiler之类的东西将C代码转换为可直接在浏览器中运行的JavaScript代码的可能性.

If it is client side JavaScript talking to MATLAB, I am afraid there is no easy way to make the two talk directly. MPS is still a possibility, but it will be via the server-side web app. Perhaps you can explore the possibility of using MATLAB Coder to convert the MATLAB code into C code and then use something like a transpiler to convert the C code into JavaScript code that can be run directly in the browser.

这篇关于在JavaScript中调用MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆