


function d=jacob_element(func,element,args)
returns an entry of the finite differences approximation to the jacobian of func
INPUTS
func [function name] string with name of the function
element [int] the index showing the element within the jacobian that should be returned
args [cell array] arguments provided to func
OUTPUTS
d [double] jacobian[element]
SPECIAL REQUIREMENTS
none

0001 function d=jacob_element(func,element,args) 0002 % function d=jacob_element(func,element,args) 0003 % returns an entry of the finite differences approximation to the jacobian of func 0004 % 0005 % INPUTS 0006 % func [function name] string with name of the function 0007 % element [int] the index showing the element within the jacobian that should be returned 0008 % args [cell array] arguments provided to func 0009 % 0010 % OUTPUTS 0011 % d [double] jacobian[element] 0012 % 0013 % SPECIAL REQUIREMENTS 0014 % none 0015 0016 % Copyright (C) 2010-2011 Dynare Team 0017 % 0018 % This file is part of Dynare. 0019 % 0020 % Dynare is free software: you can redistribute it and/or modify 0021 % it under the terms of the GNU General Public License as published by 0022 % the Free Software Foundation, either version 3 of the License, or 0023 % (at your option) any later version. 0024 % 0025 % Dynare is distributed in the hope that it will be useful, 0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0028 % GNU General Public License for more details. 0029 % 0030 % You should have received a copy of the GNU General Public License 0031 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0032 0033 func = str2func(func); 0034 0035 h=10e-6; 0036 pargs=args; 0037 margs=args; 0038 % length(args) is used instead of size(args, 2) to avoid to transpose column vectors 0039 for i=1:length(args) 0040 if i==element 0041 pargs{i} = pargs{i} + h; 0042 margs{i} = margs{i} - h; 0043 end 0044 end 0045 d=(func(pargs{:})... 0046 -func(margs{:}))/(2*h);