4

Is it possible to call matlab functions from Silverlight / C# ?

Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
jose
  • 2,733
  • 4
  • 37
  • 51
  • 1
    Which functions would you like to call? Why not http://mathnetnumerics.codeplex.com/ ? – Mikhail Poda Feb 05 '10 at 23:14
  • I need to call my own functions implemented in matlab and some native. But mathnumerics seems to be a great tool. Thanks! – jose Feb 09 '10 at 21:57

4 Answers4

5

If you have an assembly (dll) that can interpret Mathlab calls, you should be able to include that assembly in your project and compile it with the rest of your application.

Obviously, you won't be able to run Silverlight side-by-side to interface with an installed instance of Matlab (unless the API is exposed through COM interop and using Silverlight 4, but that could get messy).

The Web API on sourceforge, as mentioned by Matt, seems like a really good fit if you can't find assemblies to include directly within your Silverlight application. Read my comments there for further thoughts.

Ben McCormack
  • 32,086
  • 48
  • 148
  • 223
3

I dont think this will be possible for Silverlight that you are intending to run in the browser, although you certainly could using WPF as a Windows app.

However you could expose Matlab functionality as a webservice using Matlab Server Pages (MSP), and then consume the fucntionlaity from silverlight.

http://msp.sourceforge.net

Of particular interest isthis tutorial showing how to access a MSP webservice from C#.

http://msp.sourceforge.net/Tutorial/tutor13.htm

Matt
  • 1,247
  • 8
  • 16
  • 1
    The idea of consuming a web service seems like a very good fit for a silverlight application. You might have some issues with cross-domain functionality if you try to access the service directly from the Silverlight client (although this may be allowed in out-of-browser elevated trust in Silverlight 4). At the very least, you can create a web service on your host domain that interacts with matlab service on a separate domain. That should work fine in any version of SL. – Ben McCormack Feb 05 '10 at 14:44
  • You should be fine with any cross domain issues, as long as you can have control of the server where the web services are running. You just need to put a clientaccesspolicy.xml file at the root of the webservice domain. – Matt Feb 05 '10 at 14:50
  • exactly correct. At first I was thinking he would be accessing someone else's hosted service, but the sourceforge project you referenced looks like something you're supposed to host on your own domain. – Ben McCormack Feb 05 '10 at 15:21
1

You can use the Matlab API for .NET

jpabluz
  • 1,200
  • 6
  • 16
1

You will find your answer on this page http://tech-michael.blogspot.com/2010/01/silverlight-communicating-with-matlab.html

I hope this helps.

abdelaliz
  • 13
  • 2