Why does abs cause bad matlabfunction evaluation?
If I run
x = sym(‘x’,’real’);
y = sym(‘y’,’real’);
f = abs(((x – 1)^2 + y^2)^(1/2) – 1)^2 + ((x^2 + y^2)^(1/2) – 1)^2;
d2fdx2 = diff(diff(f,x),x);
[eval(subs(subs(d2fdx2,x,1),y,1)) feval(matlabFunction(d2fdx2),1,1)]
Then I see
ans =
1.2929 NaN
If I remove the abs then I get the correct evaluation for both ([1.2929 1.2929]).
I’m wondering why this abs is causing trouble in matlabFunction . (in this minimal example it’s of course easy to remove)If I run
x = sym(‘x’,’real’);
y = sym(‘y’,’real’);
f = abs(((x – 1)^2 + y^2)^(1/2) – 1)^2 + ((x^2 + y^2)^(1/2) – 1)^2;
d2fdx2 = diff(diff(f,x),x);
[eval(subs(subs(d2fdx2,x,1),y,1)) feval(matlabFunction(d2fdx2),1,1)]
Then I see
ans =
1.2929 NaN
If I remove the abs then I get the correct evaluation for both ([1.2929 1.2929]).
I’m wondering why this abs is causing trouble in matlabFunction . (in this minimal example it’s of course easy to remove) If I run
x = sym(‘x’,’real’);
y = sym(‘y’,’real’);
f = abs(((x – 1)^2 + y^2)^(1/2) – 1)^2 + ((x^2 + y^2)^(1/2) – 1)^2;
d2fdx2 = diff(diff(f,x),x);
[eval(subs(subs(d2fdx2,x,1),y,1)) feval(matlabFunction(d2fdx2),1,1)]
Then I see
ans =
1.2929 NaN
If I remove the abs then I get the correct evaluation for both ([1.2929 1.2929]).
I’m wondering why this abs is causing trouble in matlabFunction . (in this minimal example it’s of course easy to remove) symbolic, matlabfunction, diff, abs MATLAB Answers — New Questions