Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vectorfield

Vector Field Plotting


Description

Plotting a vector field

Usage

vectorfield(fun, xlim, ylim, n = 16,
            scale = 0.05, col = "green", ...)

Arguments

fun

function of two variables — must be vectorized.

xlim

range of x values.

ylim

range of y values.

n

grid size, proposed 16 in each direction.

scale

scales the length of the arrows.

col

arrow color, proposed ‘green’.

...

more options presented to the arrows primitive.

Details

Plots a vector field for a function f. Main usage could be to plot the solution of a differential equation into the same graph.

Value

Opens a graph window and plots the vector field.

See Also

Examples

f <- function(x, y) x^2 - y^2
xx <- c(-1, 1); yy <- c(-1, 1)
## Not run: 
vectorfield(f, xx, yy, scale = 0.1)
for (xs in seq(-1, 1, by = 0.25)) {
    sol <- rk4(f, -1, 1, xs, 100)
    lines(sol$x, sol$y, col="darkgreen")
}
grid()
## End(Not run)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.