0

タイトルが示すように、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 によってキャッチされるべきではありませんか? これは、コンパイラなしで発生します。

4

1 に答える 1

1

この問題がコンパイルとは何の関係もないと思います。通常の MATLAB でコードを実行しようとするとtest、a の変数をparfor分類できないという同じエラーが発生します。

ここにバグはありません。コードのすべての部分をparforループ内で実行できるわけではなく、MATLAB が実行前に実行できる部分とできない部分を完全に判断することはできません。それは良い仕事をしようとします、そして、そうするとき、コードアナライザーは実行前にあなたに知らせます-しかし、それができないとき、それはあなたが見つけたように実行時エラーを与えます.

おそらく、MATLAB がこの変数を分類できないことを静的に判断する方法を考えることができます。その場合、これはコード アナライザーへの拡張要求として MathWorks に報告できます。

于 2013-08-13T10:34:48.850 に答える