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?

Réponses (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 commentaires

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.

Connectez-vous pour commenter.

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

Catégories

En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by