Learn R Programming

pracma (version 1.8.8)

fplot: Plot Multivariate Function

Description

Plots components of a (multivariate) function between the specifies limits.

Usage

fplot(f, a, b, n = 101, vectorized = FALSE,
      col = 1:8, lty = 1, lwd = 1, ...)

Arguments

f
multivariate function, vectorized or not.
a, b
begin and end of the interval.
n
number of grid points.
vectorized
logical; is the function vectorized (in column form)?)
col
vector of colors; default 1:8
lty
vector of line types.
lwd
vector of line widths.
...
more parameters to be passed to the plotting routine.

Value

  • A graph, no return value.

Details

The function must be of the form y=f(x), where x is a vector whose range fulfills the limits, and y is a vector. If the function returns more than one value for a given x, then y is a matrix whose columns contain each component of f(x).

For example, if f(x) returns (f1(x),f2(x),f3(x)) then for input (x1,x2) the function should return the matrix

f1(x1) f2(x1) f3(x1) f1(x2) f2(x2) f3(x2)

At least, this is assumed when vectorized=TRUE. If this is not the case or it turns out that size(f(c(a,b)), 1) is not 2, then this function matrix will be generated in a loop.

See Also

matplot

Examples

Run this code
f <- function(x) cbind(x, x^2, x^3, x^4, x^5, x^6, x^7, x^8)
fplot(f, 0, 1)

Run the code above in your browser using DataLab