Skip to content

gradient

1 message · David Winsemius

#
On Mar 31, 2012, at 3:58 PM, mariam behboudi wrote:

            
I'm not a matlab user,  but perhaps if you define 'F' to be an n- 
column matrix and require 'h' to be of length one:

gradient <- function(F,h) { if( !is.matrix(F) | length(h) == 0 )  
{ stop() }
      return( apply(F ,2, diff)/h)  }

(The grad function in numDeriv takes a function as its first argument  
which is not what I thought you were asking for.)