6

This was asked before, but the solution doesn't seem to work on MacOS. Wolfram Library has a package for 7 year old Matlab version. Is there a solution that works on MacOS 10.6 and Matlab 7.9?

I want to call CVX from Mathematica

Community
  • 1
  • 1
Yaroslav Bulatov
  • 57,332
  • 22
  • 139
  • 197
  • 1
    I've only tried invoking mma from Matlab using the Mathematica Symbolic Toolbox on Mathworks FileExchange, so I don't have an answer for you. That being said, both Matlab and Mathematica integrate pretty well with Java; in particular, calling Java classes from Mathematica is very easy. Perhaps JMI (http://undocumentedmatlab.com/blog/jmi-java-to-matlab-interface/) on Matlab's side combined with JLink on mma side could do the trick... – Leo Alekseyev Mar 02 '11 at 08:14
  • Calling Java classes from Matlab is also very easy, other way round is hard. I've had some success with Matlab Builder JA, but this meant making a wrapper for every Matlab function I wanted to call from outside – Yaroslav Bulatov Mar 03 '11 at 23:13
  • I hope you find something easier, but in case everything else fails, you'll have to code your own solution. I can feel your pain, I'm facing a similar problem, where there are no official packages for connecting the 2 applications I'm interested in. Try this Wikipedia page for a summary of [inter-process communication](http://en.wikipedia.org/wiki/Inter-process_communication) methods. –  Mar 12 '11 at 21:23
  • Take a look at [MATLink](http://rsmenon.github.io/MATLink/). :) – Szabolcs May 03 '13 at 00:38

2 Answers2

2

You could use RunThrough["command",expr], this runs the external command command, and feeds expr (a Mathematica expression) as input to command

An example of a suitable command would be "matlab -r \"matlab expr\"", you could place your CVX specific code in the "matlab expr" string.

tlehman
  • 5,125
  • 2
  • 33
  • 51
2

Update: Right now, probably MATLink is the best way to do this. It works on Windows/Linux/Mac.

Disclosure: I'm one of MATLink's authors.


Have you tried using the newer mEngine instead? I can only try it on Windows, but after looking at the sources, I believe it might work on other platforms too.

Hopefully you only need to modify main.c, actually just copy and paste the main function from one of the MathLink examples (e.g. addtwo), as mEngine's main.c has the non-Windows-specific part removed. Then compile the package as a MathLink program.

Szabolcs
  • 24,728
  • 9
  • 85
  • 174
  • Wow, thanks for bringing Matlink to my attention. Looks promising, I'll give it a whirl soon. I probably shouldn't upvote this answer for the as-yet-untried benefits of Matlink, but I am doing so anyway. – High Performance Mark Jul 03 '13 at 10:38