MATLAB Answers

# division by zero problem

7 views (last 30 days)
Teerapong Poltue on 7 Nov 2020
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});
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Matt J on 7 Nov 2020
k = matlabFunction(de/no);
[A,B,C] = meshgrid(-3:0.1:3);
cur = k(A,B,C);
##### 1 CommentShowHide None
Teerapong Poltue on 7 Nov 2020
Thanks a lot

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!