Error: Transparency violation error.
조회 수: 43 (최근 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
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!