【发布时间】:2013-06-24 13:54:04
【问题描述】:
我成功地从我自己的 Web 界面通过 CLI 制作了一些由 matlab 执行的脚本。但现在,我正在尝试获取我们可以从中启动的脚本的输出。
有谁知道如何获取matlab返回的值?
例如,我的脚本“A.m”是:
a = [3, 6, 9];
我想得到:
a =
3 6 9
我的脚本“B.m”是:
a = [1 2 3 4 6 4 3 4 5]
b = a + 2
plot(b)
grid on
我想得到下面的结果 + 生成的图像:
a =
1 2 3 4 6 4 3 4 5
b =
3 4 5 6 8 6 5 6 7
我使用过这些以前的主题:
- Matlab: Running an m-file from command-line
- Make PHP wait for Matlab script to finish executing
- How can I stop MATLAB from returning until after a command-line script completes?
- get output from shell_exec command as command runs
非常感谢!
编辑: 我这样称呼我的文件:
C:\...\matlab\bin> matlab -wait -minimize -nodesktop
-automation -r "run('C:\...\Source2.m');exit;"
【问题讨论】:
-
为什么不将结果保存到 mat 文件中,然后再读取结果?
-
因为我不会自己写所有的源文件。我不确定将发布这些脚本的科学家是否会一直考虑这样做。所以,我认为获得结果是最好的方法。我会将它们显示在我的网页上。
-
作为一名科学家,我会对您的完整解决方案非常感兴趣(从 HTML 代码、PHP 代码到 Matlab 代码)!如果你有时间写一个更广泛的问答对,比如“我如何从网络上运行 Matlab 脚本”,我认为这对社区真的很有帮助! (回答您自己的问题是可能的,甚至是鼓励的。)
-
是的,最终目标是从网络上运行它,但为了满足更广泛软件的需求。我还有很多工作要做。这是科学家们真正需要的。
-
您阅读过 MathWorks 的“Web 示例指南”吗? mathworks.com/help/pdf_doc/compiler/example_guide.pdf
标签: matlab web command-line-interface output