How can I load mat data in 'parsim' local workers ?

2 次查看(过去 30 天)
Hi, all, I'm not an expert on parallel simulations so I explain here my problem:
I created a simulink project, it runs without problems, inside it there are many matlab user defined functions with "load" who takes data from the workspace previously generated using a preload function (command line in simulink executed before the simlation starts).
I'm trying to replicate it using the Parsim tool of matlab, but I get an error since the workers are still using another path and the preload is uneffective. How can I workaround this issue ? I put here also a possible solution, but I cannot apply it in my case without a pragmatic example.
thanks !
here is my code:
Geo_sweep = [1 2 3]; % three locations
numSims = length(Geo_sweep);
mdl1 = 'system_270621Hybrid6';
% open_system(mdl1)
for i = numSims:-1:1
in(i) = Simulink.SimulationInput(mdl1);
in(i) = setBlockParameter(in(i), [mdl1 '/wheather_sun data'], 'GeoSelector', num2str(Geo_sweep(i)));
end
%start parallel simulation
% setupFcn = @()addpath(pwd);
poolobj = parpool('local',3);
addAttachedFiles(poolobj,{'tutto.mat'});
setupFcn = @()evalin('base','load tutto.mat' );
% out_Hybrid = parsim(in,'ShowSimulationManager', 'on','ShowProgress','on','TransferBaseWorkspaceVariables','on','SetupFcn',setupFcn)
out_Hybrid = parsim(in,'ShowSimulationManager', 'on','ShowProgress','on','SetupFcn',setupFcn)
  1 个评论
Rahul Kumar
Rahul Kumar 2022-4-8
Can you provide some more details? Is the setupFcn throwing an error? It would be good to paste the exact text of the error message.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by