Error: Transparency violation error.
76 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi I have a mfile(mfileinmfile_trial.m) in which i am calling another mfile(for_example.m) which inturn runs 2 simulink models. I am using a for loop to run this simulation. Bute when i change the for loop to parfor loop i get these errors
"" Error using for_example (line 1)
Transparency violation error.
See Parallel Computing Toolbox documentation about Transparency.
Error in mfileinmfile_trial (line 5)
parfor i=1:q
Caused by:
Error using clear
Transparency violation error.
See Parallel Computing Toolbox documentation about Transparency. ""
Can you please help out with the solution...
The code of "mfileinmfile_trial.m" is:
clear all
clc
q=1;
parfor i=1:q
%for i=1:q
%parfor_example_WS;
for_example;
end
0 commentaires
Réponses (1)
Edric Ellis
le 4 Déc 2013
Modifié(e) : Edric Ellis
le 2 Mar 2023
Transparency violations occur when you try to add variables to the body of the PARFOR loop in a way that isn't clear from the text of the PARFOR loop. See this section of Loren's blog for some more details, or the documentation.
I presume 'for_example' is a script. This probably creates new variables - this is a transparency violation. Try making 'for_example' a function. To work with Simulink models, you may well need to
assignin('base', 'paramName', value)
so that Simulink can see the values.
0 commentaires
Voir également
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!