undefined function or method 'impl' for input arguments of type 'function_handle'.

I keep putting in
f=@(x,y,z) x.ˆ2+y.ˆ2?z.ˆ2;
corners=[?2 2 ? 2 2 ? 2 2];
subplot(2,2,1)
impl(f,corners,1)
title(c = 1)
subplot(2,2,2)
impl(f,corners,.1)
title(c = .1)
subplot(2,2,3)
impl(f,corners,0)
title(c = 0)
subplot(2,2,4)
impl(f,corners,?.5)
title(c = ?.5)
and I keep getting undefined function or method 'impl' for input arguments of type 'function_handle'.
what am i doing wrong?

回答(3 个)

What is it supposed to be? I don't see any "impl" function documented as part of MATLAB.
Since you are the one using impl, whether it is a function or a variable, why not tell us what it is? If it is supposed to be a variable (I am guessing no, or you are using it incorrectly), where did you define it? If it is supposed to be a function, is it on your search path (probably not, but why do you think it should be)?

2 个评论

It can't be a variable: variables don't allow non-integer indexing. Well, not unless you design your own custom class.
... which is why I said that it was being used incorrectly if it was a variable... you never know.

请先登录,再进行评论。

function out = impl(f, corners, c) % see impl.m in [Cooper]
xmin = corners(1); ymin = corners(3); zmin = corners(5);
xmax = corners(2); ymax = corners(4); zmax = corners(6);
x = linspace(xmin, xmax ,21); y = linspace(ymin, ymax, 21);
z = linspace(zmin, zmax, 21); [XX, YY, ZZ] = meshgrid(x, y, z);
W = feval(f, XX, YY, ZZ);
m = min(min(min(W))); M = max(max(max(W)));
sprintf( 'The max over this domain is % 5.5f %', M)
sprintf( 'The min over this domain is % 5.5f %', m)
if c < m | c > M
sprintf( 'In this domain, the function does not take on the value % 5.5f %', c)
else
[X, Y] = meshgrid(x, y);
dz = (zmax - zmin)/40;
for zz = zmin : dz : zmax
Z = feval(f, X, Y, zz);
con = contours(X, Y, Z, [c,c]);
nn = size(con, 2);
if nn > 0
j = 1; while j < nn
npairs = con(2, j);
xdata = con(1, j + 1: j + npairs);
ydata = con(2, j + 1: j + npairs);
plot3(xdata, ydata, zz + 0*xdata)
j = j + npairs + 1; hold on
end;
end;
end;
end
axis(corners);
xlabel('x'); ylabel('y'); zlabel('z'); hold off

类别

帮助中心File Exchange 中查找有关 Performance and Memory 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by