Error: Transparency violation error.

73 visualizaciones (últimos 30 días)
Abhishek M
Abhishek M el 4 de Dic. de 2013
Editada: Edric Ellis el 2 de Mzo. de 2023
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

Respuestas (1)

Edric Ellis
Edric Ellis el 4 de Dic. de 2013
Editada: Edric Ellis el 2 de Mzo. de 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.
There's more about running Simulink in parallel using parsim here.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by