Go to the previous, next section.
Unless otherwise noted, all of the functions described in this chapter will work for real and complex scalar or matrix arguments.
The following functions are available for working with complex numbers. Each expects a single argument, and given a matrix, they work on an element by element basis.
ceil (x)
ceil (real (x)) + ceil (imag (x)) * I
.
floor (x)
floor (real (x)) + floor (imag (x)) * I
.
fix (x)
fix (real (x)) + fix (imag (x)) * I
.
round (x)
round (real (x)) + round (imag (x)) * I
.
sign (x)
For complex arguments, sign
returns x ./ abs (x)
.
exp (x)
gcd (x, ...
)
gcd (a1, ..., ak)
is the same as
gcd ([a1, ..., ak])
An optional second return value, v contains an integer vector such that
g = v(1) * a(k) + ... + v(k) * a(k)
lcm (x, ...
)
lcm (a1, ..., ak)
is the same as
lcm ([a1, ..., ak]).
log (x)
log2 (x)
log10 (x)
sqrt (x)
max (x)
max (max (x))
returns the largest element of x.
For complex arguments, the magnitude of the elements are used for comparison.
min (x)
max
, but return the minimum value.
rem (x, y)
x / y
, computed using the
expression
x - y .* fix (x ./ y)
An error message is printed if the dimensions of the arguments do not agree, or if either of the arguments is complex.
The following functions are available for working with complex numbers. Each expects a single argument. Given a matrix they work on an element by element basis.
abs (x)
angle (x)
arg (x)
conj (x)
imag (x)
real (x)
Octave provides the following trigonometric functions:
sin asin sinh asinh cos acos cosh acosh tan atan tanh atanh sec asec sech asech csc acsc csch acsch cot acot coth acoth
Each of these functions expect a single argument. For matrix arguments, they work on an element by element basis. For example, the expression
sin ([1, 2; 3, 4])
produces
ans = 0.84147 0.90930 0.14112 -0.75680
sum (x)
prod (x)
cumsum (x)
cumsum ([1, 2; 3, 4])
produces
ans = 1 2 4 6
cumprod (x)
cumprod ([1, 2; 3, 4])
produces
ans = 1 2 3 8
sumsq (x)
beta
betai (a, b, x)
If x has more than one component, both a and b must be scalars. If x is a scalar, a and b must be of compatible dimensions.
erf
erfc (z)
1 - erf (z)
.
erfinv
gamma (z)
gammai (a, x)
If a is scalar, then gammai (a, x)
is returned
for each element of x and vice versa.
If neither a nor x is scalar, the sizes of a and x must agree, and gammai is applied element-by-element.
lgamma
Go to the previous, next section.