Frage
„FUN muss einen String oder Inline-Funktion sein:“ Was ist die Bedeutung der Nachricht in Octave „FUN muss ein String oder Inline-Funktion sein“?Octave
In Octave 4.2.0 (Windows) versuche ich Gradients, Gradient Plots and Tangent Planes laufen, die ursprünglich in MATLAB 7.8 implementiert ist, und bekam den Fehler wie folgt.
Bitte geben Sie an, dass Octave mit MATLAB oder aus anderen Gründen nicht kompatibel ist. Wenn es einen Workaround gibt, schlagen Sie bitte vor.
>> syms x y z
>> f=((x^2-1)+(y^2-4)+(x^2-1)*(y^2-4))/(x^2+y^2+1)^2
f = (sym)
2 2 /2 \/2 \
x + y + \x - 1/*\y - 4/ - 5
-------------------------------
2
/2 2 \
\x + y + 1/
>> gradf=jacobian(f,[x,y])
gradf = (sym 1x2 matrix)
[ /2 2 /2 \/2 \ \ /2 \ /2 2
[ 4*x*\x + y + \x - 1/*\y - 4/ - 5/ 2*x*\y - 4/ + 2*x 4*y*\x + y
[- ------------------------------------- + ------------------ - -------------
[ 3 2
[ /2 2 \ /2 2 \ /
[ \x + y + 1/ \x + y + 1/ \
/2 \/2 \ \ /2 \ ]
+ \x - 1/*\y - 4/ - 5/ 2*y*\x - 1/ + 2*y]
------------------------ + ------------------]
3 2 ]
2 2 \ /2 2 \ ]
x + y + 1/ \x + y + 1/ ]
>> [xx, yy] = meshgrid(-3:.1:3,-3:.1:3);
>> ffun = @(x,y) eval(vectorize(f));
>> fxfun = @(x,y) eval(vectorize(gradf(1)));
>> fyfun = @(x,y) eval(vectorize(gradf(2)));
>> contour(xx, yy, ffun(xx,yy), 30)
error: vectorize: FUN must be a string or inline function
error: called from
@<anonymous> at line 1 column 15