Error: Transparency violation error.

67 次查看(过去 30 天)
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

回答(1 个)

Edric Ellis
Edric Ellis 2013-12-4
编辑:Edric Ellis 2023-3-2
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.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by