私は同じ問題を抱えていました。警告によってコードの機能が変更されることはありませんが、有用な出力のためにコマンド ウィンドウを使用しようとしている場合は苦痛です。警告は膨大な数の 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