MatlabFunction error: Argument 'vars' failed validation isVars.
3 ビュー (過去 30 日間)
古いコメントを表示
here In my program, I calculate the symbolic gradient and evaluate them with given values.However,when I enconter a error when using the MatlabFunction. The error says
Error using sym/matlabFunction>getOptions (line 500)
Argument 'vars' failed validation isVars.
Error in sym/matlabFunction (line 100)
opts = getOptions(args);
Error in mini_dist (line 54)
matlabFunction(dfb,'file',filename,'vars',b);
The related part of my program is
[b,fun,flag] = fminunc(@cov,b0);
%dfb = gradient(fcn,b);
nT = T_z + T_e;
B = sym('B', [nT, 1]);
temp = fcn(B); %zt and et are not defined until fcn is run
v = [zt;et];
dfb = jacobian(temp,v);
currdir = [pwd filesep]; % You may need to use currdir = pwd
filename = [currdir,'gradient.m'];
matlabFunction(dfb,'file',filename,'vars',b); % Line-54 %
And the full code and data see attachment
Thank you for your advice
0 件のコメント
回答 (1 件)
Walter Roberson
2016 年 11 月 20 日
You have
[b,fun,flag] = fminunc(@cov,b0);
so your b is numeric.
You have
matlabFunction(dfb,'file',filename,'vars',b); % Line-54 %
but your b is numeric.
You should possibly be passing in B or v rather than b.
When I tested your code before, the returned jacobian had only numeric entries and no variables; I did not test your current code. You need to think more about how your jacobian is to be used.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!