Combining Matlab & JavaScript: Methods of integration?

为君一笑 提交于 2019-12-05 05:23:13

问题


I have a MatLab script that I would like to use in my Javascript algorithm. Is there any way of getting JavaScript to call a MatLab script? Better yet, is there any way to loosely couple a MatLab script and a Javascript page?

I found this one page that discussed using .NET server to hold the MatLab script/code (http://www.mathworks.com/matlabcentral/answers/9521), but are there any other easier methods to get this working?

I would much rather not have to re-code the MatLab in JavaScript. Ideally, I would like to use my JavaScript as it currently works to spit a string of a specified format into a MatLab script directly and access its string output after that algorithm is done.

What are the ways in which I can do this? If there is only the .NET or similar approach, does anyone have good resources to guide how to do this carefully or even better, personal experience with how to set this up?

Thank you in advance.

Revisit NOTE (Dec 17, 2013) & Decision Made: It turns out that in the end it proved easier to just re-code my MatLab script into JavaScript. Google Closure was released for JavaScript a while ago, and it provides a beautiful bit of extended functionality to the JavaScript language, and I highly recommend it to anyone interested in using it. I particularly made use of its Matrix library, which allowed me to re-code & design my Nodal Voltage Analysis method in JavaScript. Check it out: https://developers.google.com/closure/


回答1:


For deployment matlab will always need to be run on server side mostly via java or .net. However you can use javascript and matlab inside matlabs browser. Its not very pretty and makes use of the matlab: command. A tutorial is given here and the bellow code executes the why script.

<a href=”matlab:why”>Why?</a>



回答2:


From the 16B version there is a way to talk to MATLAB from JavaScript using MPS and RESTFUL. Here is am example link http://www.mathworks.com/help/mps/restfuljson/example-web-based-bond-pricing-tool-using-javascript.html



来源:https://stackoverflow.com/questions/16045527/combining-matlab-javascript-methods-of-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!