Octave:General mathematical functions
From AIMSWiki
WARNING: This page is still under heavy construction
Functions
sum(x,dim) This gives the sum of the elements along the dimension "dim". If "dim" is omitted it defaults to 1. Also, if x is a vector and "dim" is omitted, it will return the sum of the elements.
Example: sum([true,true,true])
ans = 3
sum(x,'native') If the optional argument 'native' is given, then the sum is performed in the same type as the original argument, rather than in the default double type.
Example: sum([true,true,true],'native')
ans = true
prod(x,dim) This gives the product of the elements along the dimension "dim". If "dim" is omitted it defaults to 1. Also, if x is a vector and "dim" is omitted, it will return the product of the elements.
Example: prod([3,5,6])
ans = 90
nchoosek(n,k) This gives the number of possible combinations of choosing "k" elements from a group of "n" objects. It is the equivalent of the equation: n! / [k! (n-k)!].
Example: nchoosek(5,2)
ans = 10
Status of Variables
The function who and its siblings whos, whos_line_format and who -variables will show different information about what is in memory. This can be convenient if we need to see which variables are available at the prompt.
Command: who
Command: whos
List currently defined symbols matching the given patterns. The following are valid options. They may be shortened to one character but may not be combined.
-all List all currently defined symbols.
-builtins List built-in functions. This includes all currently compiled function files, but does not include all function files that are in the search path.
-functions List user-defined functions. -long Print a long listing including the type and dimensions of any symbols. The symbols in the first column of output indicate whether it is possible to redefine the symbol, and whether it is possible for it to be cleared.
-variables List user-defined variables.
By default, only user defined functions and variables visible in the local scope are displayed.
Example here the whos function is used to identify the size of a matrix (variable x).
octave-3.0.1.exe:1> x=[1,2,3;3,4,2;5,6,7;2,1,2] 1 3 5 2 2 4 6 1 3 2 7 2
octave-3.0.1.exe:2> whos x Prot Name Size Bytes Class ==== ==== ==== ===== ===== rwd x 3x4 96 double
Return to the Octave index

