https://github.com/cran/pracma
Raw File
Tip revision: 392ae21a013fb3f518e8f9eb8efb458a55a2eca2 authored by HwB on 09 April 2011, 00:00:00 UTC
version 0.3-0
Tip revision: 392ae21
piecewise.Rd
\name{piecewise}
\alias{piecewise}
\title{
Piecewise Linear Function
}
\description{
  Compute zeros and area of a piecewise linear function.
}
\usage{
piecewise(x, y, abs = FALSE)
}
\arguments{
  \item{x}{x-coordinates of points defining the piecewise linear function}
  \item{y}{x-coordinates of points defining the piecewise linear function}
  \item{abs}{logical; shall the integral or the total area between the
             x-axis and the function be calculated}
}
\details{
  Compute zeros and integral resp. area of a piecewise linear function
  given by points with x and y as coordinates.
}
\value{
  Returns a list with the integral or area as first element and the vector
  as all zeroes as second.
}
\author{
  HwB  <hwborchers@googlemail.com>
}
\seealso{
\code{\link{trapz}}
}
\examples{
x <- c(0,  2, 3,  4, 5)
y <- c(2, -2, 0, -2, 0)
piecewise(x, y)
piecewise(x, y, abs=TRUE)
}
\keyword{ math }
back to top