タイトルが示すように、arrayfun を内部で使用する parfor ループが必要です。
問題の最小限の作業例を作成しました:
というファイルに次の行を含める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 によってキャッチされるべきではありませんか? これは、コンパイラなしで発生します。