How can I load mat data in 'parsim' local workers ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Rahul Kumar
il 8 Apr 2022
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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Manual Performance Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!