【发布时间】:2020-04-17 04:30:24
【问题描述】:
我想在 MATLAB 上运行一些测试,这通常需要 2 天,我有 3 个这样的测试(所以 3 x 2 = 6 天)。 因此,我在我的 Windows 机器上运行三个 MATLAB 会话并运行我的三个测试(并行),这将我的测试时间从 6 天减少到 2 天。
我想在 python 上做类似的事情来调用三个 MATLAB 实例。(我可以串行执行,但不能并行执行)
import matlab.engine as MAT_E
eng=MAT_E.start_matlab()
test_id=1
isTestDone = eng.runTest1(test_id,nargout=1) # runTest1 is a .m file which needs to be run
test_id=2
isTestDone = eng.runTest2(test_id,nargout=1) # runTest2 is a .m file which needs to be run
test_id=3
isTestDone = eng.runTest3(test_id,nargout=1) # runTest3 is a .m file which needs to be run
有谁知道我如何同时做类似的事情?
如果您有任何问题/建议/cmets,请告诉我?
编辑/添加了 runTest1 骨架
function out1 = runTest1(test_id)
% some processing happens and variable 'x' is generated
if x < 0.1
% some warning
warning('the samples are incosistent')
keyboard;
end
if x > 99
error('simulation encountered some out of bound values')
end
# some more processing
end
【问题讨论】: