<< CL_dMult Math CL_detectZero >>

CelestLab >> Math > CL_detectSign

CL_detectSign

Intervals of positive or negative values

Calling Sequence

[xres, yres] = CL_detectSign(x, y, sgn [, ytol, xbounds, opts])

Description

Parameters

x:

Abscissae. (1xN)

y:

(1xN or list) Corresponding ordinates or list(function, ...). See above for details.

sgn:

(string) Wanted sign for y: "+" or "-".

ytol:

(optional) Accuracy on y (empty <=> default value). Default value <= max(abs(y)) / 1.e8.

xbounds:

(optional) Abscissae intervals where the results are looked-for. Default value is [-%inf, %inf]. (2xQ)

opts:

(structure, optional) Additional options - see above

xres:

Intervals of abscissae where y has the requested sign. (2xP)

yres:

Corresponding ordinates. (2xP)

Authors

See also

Examples

x = 0 : 10;
a = 0.99;

// Example 1: Data interpolation
y = sin(x) - a;
xres = CL_detectSign(x, y, "+");
sin(xres) - a  // => ~0 (includes effect of interpolation errors)

// Example 2: User-defined function
function [y]=myfunction(x, c)
y = sin(x) - c;
endfunction
xres = CL_detectSign(x, list(myfunction, a), "+");
myfunction(xres, a)  // => ~0 (more accurate)

Report an issue
<< CL_dMult Math CL_detectZero >>