Execute run phase of Simulink model in parallel
2 次查看(过去 30 天)
显示 更早的评论
I want to get the output using the function model(t,x,u,'outputs'). I have a large set of inputs, which I normally pass to the model in a for loop. I have already compiled the model before the loop using model([],[],[],'compile'). When I replaced the for with a parfor loop, it does not see the model as 'compiled'. I get the error: Error, 'model' must be compiled before it can be accessed programmatically.
I don't want to compile the model inside the loop as it would make it very slow and destroy the whole purpose of using parallelization. How can I solve this?
0 个评论
回答(1 个)
Edric Ellis
2016-10-3
You can use parfevalOnAll to run the 'compile' and 'term' phases, like so:
parfevalOnAll(@vdp, 0, [], [], [], 'compile');
parfor t = 1:10
out{t} = vdp(t, [0; 0], [], 'outputs');
end
parfevalOnAll(@vdp, 0, [], [], [], 'term');
3 个评论
Edric Ellis
2016-10-5
Strange. Did it fail the second time in a MATLAB session, or when you restarted MATLAB?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model Compatibility 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!