bug in matlabFunction when passing unspecified symbolic function?
2 views (last 30 days)
Show older comments
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)
%NLCONFUNC
% D1 = NLCONFUNC(X,Y,Z)
% This function was generated by the Symbolic Math Toolbox version 6.0.
% 21-May-2014 18:46:17
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)
%NLCONFUNC
% D3 = NLCONFUNC(X,Y,Z)
% This function was generated by the Symbolic Math Toolbox version 6.0.
% 21-May-2014 17:03:56
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?
0 Comments
Answers (1)
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!