Hi
the function matlabFunction seems to do a mistake with undefined functions.
It seems to work all right if there is only one reference to the unknown function, but not if there is more than one. This is most easily seen by testing this code: only the first call of matlabFunction gives me the right output.
clear all
syms x y z f(x,y,z)
E=x + y + f(x,y,z)
D1= diff(E,x)
D2= [diff(E,x) diff(E,y) diff(E,z)]
matlabFunction(D1,'file','NlconFunc','vars',{x,y,z});
matlabFunction(D2,'file','NlconFunc','vars',{x,y,z});
For the first call of matlabfuction the generated code is as i would expect it
function D1 = NlconFunc(x,y,z)
D1 = diff(f(x,y,z),x)+1.0;
For the last call of matlabfunction the references to the derivative of f are missing. the generated code is:
function D3 = NlconFunc(x,y,z)
t2 = f(x,y,z);
D3 = [1.0,1.0,0.0];
Is this a bug (i tried 2013b 64bit and 2014a 32bit) or what did I do wrong?