Error: Transparency violation error.

74 views (last 30 days)
Abhishek M
Abhishek M on 4 Dec 2013
Edited: Edric Ellis on 2 Mar 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

Answers (1)

Edric Ellis
Edric Ellis on 4 Dec 2013
Edited: Edric Ellis on 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.
There's more about running Simulink in parallel using parsim here.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!