Learn R Programming

ramify (version 0.4.0)

meshgrid: Rectangular 2-D Grid

Description

Creates matrices for vectorized evaluations of 2-D scalar/vector fields over 2-D grids.

Usage

meshgrid(x, y = x)

Value

A list of matrices.

Arguments

x

Numeric vector representing the first coordinate of the grid.

y

Numeric vector representing the second coordinate of the grid.

See Also

Examples

Run this code
mg <- meshgrid(linspace(-4 * pi, 4 * pi, 27)) # list of input matrices
z <- cos(mg[[1]]^2 + mg[[2]]^2) * exp(-sqrt(mg[[1]]^2 + mg[[2]]^2) / 6)
image(z, axes = FALSE) # color image
contour(z, add = TRUE, drawlabels = FALSE) # add contour lines

Run the code above in your browser using DataLab