|
Size: 4735
Comment:
|
← Revision 11 as of 2026-01-19 16:03:56 ⇥
Size: 5249
Comment: More functions
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 17: | Line 17: |
| ||'''Name''' ||'''Meaning''' || ||`abs(x)` ||absolute value || ||`ceil(x)` ||round toward positive infinity || ||`exp(x)` ||exponentiation || ||`factorial(x)`||factorial || ||`fix(x)` ||round toward 0 || ||`floor(x)` ||round toward negative infinity || ||`log(x)` ||natural logarithm || ||`log10(x)` ||base-10 logarithm || ||`mod(x,d)` ||modulo of ''x'' divided by ''d''|| ||`nthroot(x,n)`||''n''th root of ''x'' || ||`round(x)` ||round to integer || ||`sqrt(x)` ||square root || |
||'''Name''' ||'''Meaning''' ||'''Notes'''|| ||`abs(x)` ||absolute value || || ||`ceil(x)` ||round toward positive infinity || || ||`exp(x)` ||exponentiation || || ||`factorial(x)`||factorial || || ||`fix(x)` ||round toward 0 || || ||`floor(x)` ||round toward negative infinity || || ||`log(x)` ||natural logarithm || || ||`log10(x)` ||base-10 logarithm || || ||`max(x)` ||maximum ||optionally return index of maximum as well: `[m,i]=max(x)`|| ||`min(x)` ||minimum ||optionally return index of minimum as well: `[m,i]=min(x)`|| ||`mod(x,d)` ||modulo of ''x'' divided by ''d''|| || ||`nthroot(x,n)`||''n''th root of ''x'' || || ||`round(x)` ||round to integer || || ||`sqrt(x)` ||square root || || |
| Line 92: | Line 94: |
| These functions return a matrix: | These functions create a matrix from other types: |
| Line 104: | Line 106: |
| These functions operate on a matrix: | These functions operate on a matrix and return other types: |
| Line 107: | Line 109: |
| ||`det(m)` ||determinant || | |
| Line 108: | Line 111: |
| ||`eig(m)` ||vector of eigenvalues || | |
| Line 110: | Line 114: |
| These functions transform a matrix: | |
| Line 111: | Line 116: |
| ---- /!\ '''Edit conflict - other version:''' ---- | ||'''Name''' ||'''Meaning'''|| ||`inv(m)` ||invert || ||`transpose(m)`||transpose || |
| Line 113: | Line 121: |
---- /!\ '''Edit conflict - your version:''' ---- As an example of the `size` function: ---- /!\ '''End of edit conflict''' ---- |
|
| Line 126: | Line 129: |
---- /!\ '''Edit conflict - other version:''' ---- |
|
| Line 133: | Line 134: |
| }}} | |
| Line 134: | Line 136: |
| ---- /!\ '''Edit conflict - your version:''' ---- | ---- |
| Line 136: | Line 138: |
| ---- /!\ '''End of edit conflict''' ---- }}} |
== Vector Functions == These functions operate on matrices that are specifically of sizes ''1 x n'' or ''n x 1''. MATLAB generally can work with either row or column vectors. ||'''Name''' ||'''Meaning''' || ||`cross(a,b)`||Cross product || ||`dot(a,b)` ||Dot product || |
| Line 142: | Line 151: |
| ---- /!\ '''Edit conflict - other version:''' ---- | |
| Line 145: | Line 153: |
---- /!\ '''Edit conflict - your version:''' ---- ---- CategoryRicottone ---- /!\ '''End of edit conflict''' ---- |
MATLAB Built-in Functions
Several functions are built into MATLAB.
Contents
Numeric Functions
Most built-in functions operate on numeric arrays by applying the function element-wise. These include:
Mathematical functions
Name |
Meaning |
Notes |
abs(x) |
absolute value |
|
ceil(x) |
round toward positive infinity |
|
exp(x) |
exponentiation |
|
factorial(x) |
factorial |
|
fix(x) |
round toward 0 |
|
floor(x) |
round toward negative infinity |
|
log(x) |
natural logarithm |
|
log10(x) |
base-10 logarithm |
|
max(x) |
maximum |
optionally return index of maximum as well: [m,i]=max(x) |
min(x) |
minimum |
optionally return index of minimum as well: [m,i]=min(x) |
mod(x,d) |
modulo of x divided by d |
|
nthroot(x,n) |
nth root of x |
|
round(x) |
round to integer |
|
sqrt(x) |
square root |
|
Trig functions
Name |
Meaning |
sin |
sine |
cos |
cosine |
tan |
tangent |
cot |
cotangent |
sec |
secant |
csc |
cosecant |
asin |
inverse sine |
acos |
inverse cosine |
atan |
inverse tangent |
acot |
inverse cotangent |
asec |
inverse secant |
acsc |
inverse cosecant |
sinh |
hyperbolic sine |
cosh |
hyperbolic cosine |
tanh |
hyperbolic tangent |
coth |
hyperbolic cotangent |
sech |
hyperbolic secant |
csch |
hyperbolic cosecant |
asinh |
inverse hyperbolic sine |
acosh |
inverse hyperbolic cosine |
atanh |
inverse hyperbolic tangent |
acoth |
inverse hyperbolic cotangent |
asech |
inverse hyperbolic secant |
acsch |
inverse hyperbolic cosecant |
Type-checking functions
Name |
Meaning |
allfinite(x) |
are all elements finite |
anynan(x) |
are any elements NaN |
isfloat(x) |
is a floating-point array |
isinteger(x) |
is an integer array |
isnumeric(x) |
is a numeric array |
isreal(x) |
uses complex storage |
Array functions
Name |
Meaning |
linspace(a,b,n) |
row vector of n evenly-spaced elements starting at a and ending in b |
String Functions
These functions operate on a string array and return a string scalar:
Name |
Meaning |
join(s) |
join the elements of string matrix s |
join(s,d) |
join the elements of string matrix s using delimiter d |
Matrix Functions
These functions create a matrix from other types:
Name |
Meaning |
diag(v) |
diagonal matrix from vector v |
eye(n) |
n x n identity matrix |
ones(n) |
n x n matrix of 1s |
ones(r,c) |
r x c matrix of 1s |
rand(n) |
n x n matrix of random numbers |
rand(r,c) |
r x c matrix of random numbers |
zeros(n) |
n x n matrix of 0s |
zeros(r,c) |
r x c matrix of 0s |
These functions operate on a matrix and return other types:
Name |
Meaning |
det(m) |
determinant |
diag(m) |
diagonal vector from matrix m |
eig(m) |
vector of eigenvalues |
size(m) |
array of dimensions |
These functions transform a matrix:
Name |
Meaning |
inv(m) |
invert |
transpose(m) |
transpose |
To demonstrate how the size function can be used:
>> A = [12 62 93 -8];
>> sz = size(A)
sz = 1×2
1 4
>> B = zeros(size(A))
B = 1x4
0 0 0 0
Vector Functions
These functions operate on matrices that are specifically of sizes 1 x n or n x 1. MATLAB generally can work with either row or column vectors.
Name |
Meaning |
cross(a,b) |
Cross product |
dot(a,b) |
Dot product |
