How should I pick input for jocabian() function im this case?
    3 次查看(过去 30 天)
  
       显示 更早的评论
    
I want to calculate the gradient for a user-defined function using the jocabian() function.In the subfunction fcn, I pick subset from a larger parameter vector that is defined in the main program like
function fm = fcn(b)
``````
global T T_z T_e zt et
teta     =0;
zt       =b(1:T_z);           % Line-7 fcn%
et       =b(1+T_z:T_z+T_e);
dify     =zeros(T,T);
````
As one can see, [zt,et] are parameter I define in the subfunction fcn and on which I calculate the gradient. However, when I feed the input argument like the following and run the program,
[b,fun,flag]    = fminunc(@cov,b0);
v = [zt,et]';
dfb             = jacobian(fcn,v);
Matlab warned me that
    Error using fcn (line 7)
    Not enough input argument
I remark the location of error in the fcn function.I don't know why there is a problem. The definition of both et and zt seems without problem.Do I miss something?
0 个评论
回答(1 个)
  KSSV
      
      
 2016-11-18
        Check the line:
dfb  = jacobian(fcn,v);
In the above fcn is a function. You have to give input b to the function, which you have not.
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

