function_2D | R Documentation |
Create a matrix using vaector x, y and a function f(x,y) as inputs.
The returned matrix has elements positioned as would be expected an a euclidean co-ordinate grid.
This does NOT adhere to the positions built out of the outer(X, Y, FUN)
function.
function_2D(X, Y, func)
X |
Describes the (numeric) vector in the X direction |
Y |
Describes the (numeric) vector in the Y direction |
func |
Describes the function used to calculate the Z return matrix |
X and Y need to be numeric vectors.
func needs to be a function.
for plotting, please see *plot2D.mat()* and *plot2D()*
The returned value is a matrix.
The no. of columns of the matrix is equal to the no. of X-values.
The no. of rows of the matrix are equal to the no. of Y-values.
The first element f(X[1], Y[1]) is located at the matrix position Z[length(Y), 1].
The element f(X[length(X)], Y[1]) is located at the matrix position Z[length(Y), length(X)].
The element f(X[1], Y[length(Y)]) is located at the matrix position Z[1, 1].
The element f(X[length(X)], Y[length(Y)]) is located at the matrix position Z[1, length(X)].
Chitran Ghosal
#define the x-axis
X <- seq(0, 10, by = 0.01)
Y <- seq(0, 16, by = 0.01)
#define the function
patt <- function(x, y){
return(exp(-0.2*x - 0.1*y)*sin(3*x)*cos(4*y))
}
#build the Z matrix
Z <- function_2D(X, Y, patt)
#plot the matrix
plot2D.mat(X, Y, Z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.