MatlabFunction error: Argument 'vars' failed validation isVars.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 20 Nov 2016
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 commentaires
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!