MATLAB: Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.

cost functionfimplicit3

Hello,
I want to visualize a cost function of a localization problem. However if i use fimplicit3 the following warning appears: "Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments" and the plot is empty. Here is my code:
syms x y z
Jd=(-(((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 166153461756515/288230376151711744)*((1227133513142857*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/841813590016 + (8589934592000001*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/5892695130112 + (500000*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/343 - (1500000*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/343 + 47361719490181303919776257030055/4951760157141521099596496896) - (((y - 3)^2 + (z - 1)^2 + x^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 3755404798969945/288230376151711744)*((500000*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/343 - (1500000*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/343 + (8589934592000001*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/5892695130112 + (1227133513142857*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/841813590016 - 75964017393466287210169242730447/4951760157141521099596496896) - (((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 564171350756517/72057594037927936)*((8589934592000001*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/5892695130112 + (1227133513142857*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/841813590016 - (1500000*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/343 + (500000*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/343 - 4.9414e+03));
fs=@(x,y,z)double(Jd);
fimplicit3(fs,[-30 30 -30 30 -30 30]);
Due to the fact that the cost function is calculated out of a localization problem it's so huge.

Best Answer

syms x y z
Jd = (-(((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 166153461756515/288230376151711744)*((1227133513142857*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/841813590016 + (8589934592000001*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/5892695130112 + (500000*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/343 - (1500000*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/343 + 47361719490181303919776257030055/4951760157141521099596496896) - (((y - 3)^2 + (z - 1)^2 + x^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 3755404798969945/288230376151711744)*((500000*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/343 - (1500000*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/343 + (8589934592000001*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/5892695130112 + (1227133513142857*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/841813590016 - 75964017393466287210169242730447/4951760157141521099596496896) - (((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2)/343 - ((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2)/343 + 564171350756517/72057594037927936)*((8589934592000001*((y - 3)^2 + (z - 1)^2 + x^2)^(1/2))/5892695130112 + (1227133513142857*((x - 9)^2 + (z - 1/10)^2 + y^2)^(1/2))/841813590016 - (1500000*((x - 5)^2 + (y - 10)^2 + (z - 3/2)^2)^(1/2))/343 + (500000*((x - 10)^2 + (y - 8)^2 + (z - 1/10)^2)^(1/2))/343 - 4.9414e+03));
N = 20;
[X, Y, Z] = ndgrid(linspace(-30, 30, N));
result = double(subs(Jd, {x, y, z}, {X, Y, Z}));
isosurface(X, Y, Z, result, 0)
xlabel('x'); ylabel('y'); zlabel('z');
Unfortunately at the moment, my system is busy so I cannot tell how well the graphic worked. I suspect you will need to increase N to get better resolution.