Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Roberto Tascioni
Roberto Tascioni le 19 Jan 2022
Commenté : Rahul Kumar le 8 Avr 2022
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 commentaire
Rahul Kumar
Rahul Kumar le 8 Avr 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by