返回信息流调试一个识别圆的程序,运行后提示错误在c盘toolbox,如下,难道是matlab版本的有问题?
----------------------------------------------------------------------------
??? Error using ==> -
Function '-' is not defined for values of class 'single'.
Error in ==> C:\MATLAB6p5\toolbox\matlab\datafun\gradient.m
On line 61 ==> g(1,:) = (f(2,:)-f(1,:))/(h(2)-h(1));
-----------------------------------------------------------------------------
这是计算梯度的函数吧
function varargout = gradient(f,varargin)
[msg,f,ndim,loc,cflag] = parse_inputs(f,varargin);
if ~isempty(msg), error(msg); end
% Loop over each dimension. Permute so that the gradient is always taken along
% the columns.
if ndim == 1
perm = [1 2];
else
perm = [2:ndim 1]; % Cyclic permutation
end
for k = 1:ndim
[n,p] = size(f);
h = loc{k}(:);
g = zeros(size(f)); % case of singleton dimension
% Take forward differences on left and right edges
if n > 1
g(1,:) = (f(2,:) - f(1,:))/(h(2)-h(1));%错误在此行
g(n,:) = (f(n,:) - f(n-1,:))/(h(end)-h(end-1));
end
% Take centered differences on interior points
if n > 2
h = h(3:n) - h(1:n-2);
g(2:n-1,:) = (f(3:n,:)-f(1:n-2,:))./h(:,ones(p,1));
end
varargout{k} = ipermute(g,[k:ndim 1:k-1]);
% Set up for next pass through the loop
f = permute(f,perm);
end
% Swap 1 and 2 since x is the second dimension and y is the first.
if ndim>1
tmp = varargout{1};
varargout{1} = varargout{2};
varargout{2} = tmp;
end
if cflag, varargout{1} = varargout{1}.'; end
这是一条镜像帖。来源:北邮人论坛 / matlab / #5168同步于 2009/4/16
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Matlab机器人发帖
[求助]为什么提示matlab/toolbox中出错
freecross
2009/4/16镜像同步2 回复
订阅后,新回复会通过你的通知中心匿名送达。