Как следует из названия, я хочу иметь цикл parfor с внутренним использованием arrayfun.
Я создал минимальный рабочий пример для решения проблемы:
Наличие следующих строк в файле с именем thisparfortest.m
function test=thisparfortest(countmax)
parfor count=1:countmax
test(count).nummer=count;
test(count).bisdrei=arrayfun(@(testnum)eq(test(count).nummer,testnum),1:3);
end
команда mcc('-e','-v','thisparfortest')
приводит к
Compiler version: 4.18.1 (R2013a)
Error: File: **************\thisparfortest.m Line: 3 Column: 5
The variable test in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".
Processing C:\Program Files\MATLAB\R2013a\toolbox\matlab\mcc.enc
Processing include files...
2 item(s) added.
Processing directories installed with MCR...
The file mccExcludedFiles.log contains a list of functions excluded from the CTF archive.
0 item(s) added.
Generating MATLAB path for the compiled application...
Created 43 path items.
Parsing file "****************\thisparfortest.m"
(Referenced from: "Compiler Command Line").
Parsing file "C:\Program Files\MATLAB\R2013a\toolbox\compiler\deploy\deployprint.m"
(Referenced from: "Compiler Command Line").
Parsing file "C:\Program Files\MATLAB\R2013a\toolbox\compiler\deploy\printdlg.m"
(Referenced from: "Compiler Command Line").
Unable to determine function name or input/output argument count for function
in MATLAB file "thisparfortest".
Please use MLINT to determine if this file contains errors.
Error using mcc
Error executing mcc, return status = 1 (0x1).
но, как советовали, mlint thisparfortest
(а также checkcode
) возвращает без проблем - как в редакторе.
Цикл можно сделать и скомпилировать как цикл for.
Пожалуйста, не спрашивайте о смысле этих команд - они просто сюда за mwe.
Думаю, об этом нужно сообщить в mathworks - или я что-то не так сделал?
Некоторые дополнения: При запуске
function retval=thisparfortest(countmax)
helpfun=@(x)arrayfun(@(testnum)eq(x,testnum),1:3);
parfor count=1:countmax
retval(count).nummer=count^2;
retval(count).bisdrei=helpfun(retval(count).nummer);
end
только с циклом for
это работает, но при использовании показанной версии с parfor
это приводит к
Error using thisparfortest>(parfor supply) (line 3)
Undefined function or variable "retval".
Error in thisparfortest (line 3)
parfor count=1:countmax
Caused by:
Undefined function or variable "retval"
Разве это не должно быть поймано с помощью mlint/checkcode? Это происходит без компилятора.