An UndefinedFunction error was thrown on the workers with parfor

조회 수: 16 (최근 30일)
Dave Lee
Dave Lee 2018년 10월 19일
이동: Edric Ellis 2025년 8월 11일
Hi,
I got the error
An UndefinedFunction error was thrown on the workers for 'x'. This might be because the file containing 'x' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files
to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
Caused by: Undefined function or variable "x"
when running the simple code below. Can anyone please help me with this?
Thanks,
clear all;
clc;
parfor n=1:1
for m=1:2
x{n}(m) = 1;
end
y = x{n}(1)
end
  댓글 수: 3
Dave Lee
Dave Lee 2018년 10월 19일
Hi Walter,
Do you mean as below? I tried and it could run. However, Matlab highlights the error as below when I point to parfor or x (red underscores). Is that still good?
Thanks,

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 10월 19일
이동: Edric Ellis 2025년 8월 11일
x = cell(1, 1);
before the parfor.

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by