从 Mathematica 调用 Matlab 的非 Windows 方式
之前曾问过这个问题,但解决方案似乎没有在 MacOS 上工作。 Wolfram 库 有一个 7 年前的 Matlab 版本的包。是否有适用于 MacOS 10.6 和 Matlab 7.9 的解决方案?
我想从 Mathematica 调用 CVX
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 RunThrough["command",expr],这会运行外部命令
command
,并提供expr
(Mathematica 表达式)作为输入到command
合适的命令示例是
"matlab -r \"matlab expr\""
,您可以将 CVX 特定代码放在“matlab expr”字符串中。You could use
RunThrough["command",expr]
, this runs the external commandcommand
, and feedsexpr
(a Mathematica expression) as input tocommand
An example of a suitable command would be
"matlab -r \"matlab expr\""
, you could place your CVX specific code in the "matlab expr" string.更新:现在,MATLink 可能是执行此操作的最佳方法。它适用于 Windows/Linux/Mac。
披露:我是 MATLink 的作者之一。
您是否尝试过使用较新的 mEngine 代替?我只能在 Windows 上尝试,但在查看源代码后,我相信它也可以在其他平台上运行。
希望您只需要修改
main.c
,实际上只需从 MathLink 示例之一(例如 addtwo)复制并粘贴 main 函数,因为 mEngine 的main.c
有删除了非 Windows 特定部分。 然后将包编译为 MathLink 程序。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'smain.c
has the non-Windows-specific part removed. Then compile the package as a MathLink program.