On Mar 31, 2012, at 3:58 PM, mariam behboudi wrote:
Hello
In matlab we have " gradient(F,h) " where h is a scalar uses h
as the
spacing between points in each direction. Now I need to use this
function
in R. and I dont know how can I should define my function that I
haave "h"
in R?
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.)
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.