bug in matlabFunction when passing unspecified symbolic function?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!