我用不同的参数并行运行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.我以前没有见过这种情况,我不知道如何解决它。任何帮助都是非常感谢的。
发布于 2016-09-13 22:52:52
这个警告没什么好担心的。至少现在是这样。请记住,这是一个警告,所以您的代码仍然可以运行。它只是告诉您,函数nargchk已弃用,您应该使用较新的版本:narginchk和nargoutchk。您可以在nargchk的MathWorks官方文档中看到此警告:http://www.mathworks.com/help/matlab/ref/nargchk.html。我的猜测是,CVX开发的最后一个版本是在MATLAB决定做出这个决定之前。
因此,您所要做的就是进入第2行的bcompress文件,并使用narginchk更改nargchk。具体来说,在下载cvx时,打开包含代码的文件夹,然后转到/lib/@cvx/bcompress.m。将第2行的error(nargchk(1, 3, nargin));行更改为error(narginchk(1, 3));。
如果您不打算升级您的MATLAB版本,并且希望继续使用当前版本,那么您可以简单地忽略该警告。有关详细信息,请参阅narginchk上的MathWorks帮助文件:http://www.mathworks.com/help/matlab/ref/narginchk.html
发布于 2016-09-16 03:38:05
我也有同样的问题。这些警告不会改变代码的功能,但如果您试图使用命令窗口进行有用的输出,则会很麻烦。由于警告来自大量的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
endhttps://stackoverflow.com/questions/39472859
复制相似问题