func_2_arr | R Documentation |
Converts a 2D function, f:\mathbb{R}^2 \to \mathbb{R}^1
, of the form f(x,y)
to a rank-3, 3-slice array T_{m,n,p}
.
Please see details.
func_2_arr(func, X, Y)
func |
Describes the function |
X |
The X-vector over which the function should be evaluated. |
Y |
The Y-vector over which the function should be evaluated. |
The returned array, T_{m,n,p}
, will be a 3-slice array, i.e. p \in \{1, 2, 3\}
.
T_{m,n,1}
is the data matrix for f(x,y)
.
T_{m,n,2}
and T_{m,n,3}
are the X-matrix and the Y-matrix respectively.
For clearer understanding please see image.
The returned value is an R array
, (T_{ijk})_{m \times n \times p}
,.
Here m
and n
are the length of the Y vector
and X vector
respectively while p = 3
. Please see image above.
Chitran Ghosal
img_2_arr, plot2D.arr
###build the function
sines <- function(X, Y){
w1 <- 2*X+3*Y
w2 <- -3*X + Y
return(sin(w1) + sin(w2))
}
###call the function
arr <- func_2_arr(func = sines, X = seq(-10,10, by=0.05), Y = seq(-7, 7, by = 0.05))
###plot the array
plot2D.arr(arr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.