division by zero problem

2 次查看(过去 30 天)
I'm running the code
syms a b c
interval = [-3:0.1:3];
a= interval ;
b= interval;
c= interval;
[A,B,C] = meshgrid(a,b,c);
cur = subs(k,{x y z},{A B C});
which k is given by
syms x y z
f = cos(x) + cos(y) + cos(z);
fx = diff(f,x);
fy = diff(f,y);
fz = diff(f,z);
fxx = diff(fx,x);
fxy = diff(fx,y);
fxz = diff(fx,z);
fyx = diff(fy,x);
fyy = diff(fy,y);
fyz = diff(fy,z);
fzx = diff(fz,x);
fzy = diff(fz,y);
fzz = diff(fz,z);
mat = [fxx fxy fxz fx; fyx fyy fyz fy; fzx fzy fzz fz; fx fy fz 0];
no = det(mat);
de = (fx^2 + fy^2 + fz^2)^2;
k = de/no;
But it turns out that
Error using symengine
Division by zero.
Error in sym/subs>mupadsubs (line 160)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 145)
G = mupadsubs(F,X,Y);
Error in curvature (line 41)
cur = subs(k,{x y z},{A B C});

采纳的回答

Matt J
Matt J 2020-11-7
k = matlabFunction(de/no);
[A,B,C] = meshgrid(-3:0.1:3);
cur = k(A,B,C);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by