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

조회 수: 6 (최근 30일)
Makaya
Makaya 2011년 5월 3일
답변: Danilo Magistrali 2020년 4월 8일
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개)

Walter Roberson
Walter Roberson 2011년 5월 3일
What is it supposed to be? I don't see any "impl" function documented as part of MATLAB.

Matt Fig
Matt Fig 2011년 5월 3일
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
Walter Roberson
Walter Roberson 2011년 5월 3일
It can't be a variable: variables don't allow non-integer indexing. Well, not unless you design your own custom class.
Matt Fig
Matt Fig 2011년 5월 3일
... which is why I said that it was being used incorrectly if it was a variable... you never know.

댓글을 달려면 로그인하십시오.


Danilo Magistrali
Danilo Magistrali 2020년 4월 8일
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

카테고리

Help CenterFile 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