Transparency issue while adding secondary block
42 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm attempting to generate Simscape models using a parfor loop for parallel processing, but this results in a transparency violation error when adding blocks. The error points to the 'PreCopyFcn' callback in the masks of all Simscape blocks. I tried loading the libraries within the parfor loop, but this approach didn’t resolve the issue.
0 Commenti
Risposte (1)
Gayatri
il 5 Nov 2024 alle 8:23
Hi Kamal,
You can use 'parfeval' to avoid the transparency violation error. Here is an example:
1. Define a function to create Simscape model.
function foo(modelName)
ModelName = modelName; % Set up the model
proj = new_system(ModelName); % Create a new system
open_system(ModelName); % Open the new model
% Add blocks
add_block('simulink/Sinks/Scope', [ModelName '/myScope']);
add_block('fl_lib/Thermal/Thermal Elements/Thermal Mass', ...
[ModelName '/myblock'], 'Position', [250 135 300 200]);
% Save the system
save_system(ModelName);
close_system(ModelName);
end
2. Call this function using parfeval:
>> f = parfeval(@foo, 0, 'Model_1');
The parfeval function avoids issues related to callbacks and transparency by executing each instance of foo independently in parallel workers.
Please refer the below documentation for parfeval:https://www.mathworks.com/help/matlab/ref/parfeval.html
0 Commenti
Vedere anche
Categorie
Scopri di più su Parallel for-Loops (parfor) 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!