0

さまざまなパラメーターを使用して CVX を並行して実行しています。シリアルで実行すると警告は表示されませんが、(parfor を使用して) 並列で実行すると、次のようになります。

 In cvx/bcompress (line 2)
  In cvxprob/newcnstr (line 233)
  In cvxprob/newcnstr (line 72)
  In == (line 3)
  In cvx/abs (line 68)
  In cvx/norm (line 56)
  In remove_l (line 27)
  In parallel_function>make_general_channel/channel_general (line 914)
  In remoteParallelFunction (line 38)
Warning: NARGCHK will be removed in a future release. Use NARGINCHK or NARGOUTCHK instead.

これは前に見たことがなく、解決方法がわかりません。どんな助けでも大歓迎です。

4

2 に答える 2

1

警告は心配する必要はありません...少なくともすぐに。これは警告であるため、コードは引き続き実行されます。関数が非推奨であり、代わりにnargchk新しいバージョンを使用する必要があることを単に伝えています。この警告は、 http : //www.mathworks.com/help/matlab/ref/nargchk.htmlの MathWorks 公式ドキュメントで確認できます。私の推測では、開発された CVX の最後のバージョンは、MATLAB がこの決定を下す前のものでした。 narginchknargoutchknargchk

そのため、bcompressファイルの 2 行目nargchknarginchk. 具体的には、 をダウンロードするときcvxに、コードを含むフォルダーを開いてから/lib/@cvx/bcompress.m. 2 行目の行を に変更error(nargchk(1, 3, nargin));error(narginchk(1, 3));ます。

MATLAB のバージョンをアップグレードするつもりがなく、現在のバージョンを使い続けたい場合は、警告を無視してかまいません。詳細については、次の MathWorks ヘルプ ファイルを参照しnarginchkてください: http://www.mathworks.com/help/matlab/ref/narginchk.html

于 2016-09-13T14:52:52.137 に答える
0

私は同じ問題を抱えていました。警告によってコードの機能が変更されることはありませんが、有用な出力のためにコマンド ウィンドウを使用しようとしている場合は苦痛です。警告は膨大な数の CVX ファイルから発生していたので、それらをすべて修正するスクリプトを作成しました。

nargchk を使用してすべての CVX ファイルを修正するには、次のコードを「update_nargchk.m」という名前のファイルにコピーし、引数なしで cvx ルート フォルダーで実行するか、cvx ルート フォルダーを指す文字列引数を使用して別の場所から実行します。

function update_nargchk(directory)
%UPDATE_NARGCHK Updates files using the depricated nargchk
%   All files in the specified directory (or current directory if
%   unspecified) are searched. If an instance of nargchk is found being
%   used (with nargin) it is updated to use narginchk with the same values.

if ~exist('directory','var')
    directory = '.';
end

recurse(directory);

end

function recurse( folder )

d = dir(folder);
for elem = 1:length(d)
    if ~strcmp(d(elem).name,'.') && ~strcmp(d(elem).name,'..')
        if d(elem).isdir
            recurse([folder '/' d(elem).name]);
        else
            if strcmp(d(elem).name(end-1:end),'.m') 
                updateFile([folder '/' d(elem).name]);
            end
        end
    end
end

end

function updateFile(filename)

% read file contents into workspace
fid = fopen(filename);
C=textscan(fid,'%s','delimiter','\n','whitespace','');
C = C{1,1};
fclose(fid);

% check for instances of nargchk
instanceFound = false;
for k=1:numel(C)
    textline = C{k,1};
    if ~isempty(regexp(textline,'^[^%]*nargchk','ONCE')) && ...
            ~isempty(regexp(textline,'^[^%]*nargin','ONCE'))
        instanceFound = true;
        nums = regexp(textline,'(\d+|-?Inf)','tokens');
        nums = [str2double(nums{1}) str2double(nums{2})];
        C(k) = {['narginchk(' num2str(nums(1)) ',' num2str(nums(2)) '); % Modified from: ' textline]};
    end
end

if instanceFound
    % print new file
    fid = fopen(filename,'w'); % Open the file
    for k=1:numel(C)
        fprintf(fid,'%s\r\n',C{k,1});
    end
    fclose(fid);
    disp([filename ' updated'])
end

end
于 2016-09-15T19:38:04.820 に答える