Operators

!
Logical 'not' operator. See also: ~, not
!=
Logical 'not equals' operator. See also: ~=, ne
"
String delimiter.
#
Begin comment character. See also: %, #{
#{
Begin block comment. There must be nothing else, other than whitespace, in the line both before and after `#{'. It is possible to nest block comments. See also: %{, #}, #
#}
Close block comment. There must be nothing else, other than whitespace, in the line both before and after `#}'. It is possible to nest block comments. See also: %}, #{, #
%
Begin comment character. See also: #, %{
%{
Begin block comment. There must be nothing else, other than whitespace, in the line both before and after `%{'. It is possible to nest block comments. See also: #{, %}, %
%}
Close block comment. There must be nothing else, other than whitespace, in the line both before and after `%}'. It is possible to nest block comments. See also: #}, %{, %
&
Element by element logical 'and' operator. See also: &&, and
&&
Logical 'and' operator (with short-circuit evaluation). See also: &, and
'
Matrix transpose operator. For complex matrices, computes the complex conjugate (Hermitian) transpose. The single quote character may also be used to delimit strings, but it is better to use the double quote character, since that is never ambiguous. See also: .', transpose
(
Array index or function argument delimiter.
)
Array index or function argument delimiter.
*
Multiplication operator. See also: .*, times
**
Power operator. This may return complex results for real inputs. Use `realsqrt', `cbrt', `nthroot', or `realroot' to obtain real results when possible. See also: power, ^, .**, .^, realpow, realsqrt, cbrt, nthroot
+
Addition operator. See also: plus
++
Increment operator. As in C, may be applied as a prefix or postfix operator. See also: -
,
Array index, function argument, or command separator.
-
Subtraction or unary negation operator. See also: minus
--
Decrement operator. As in C, may be applied as a prefix or postfix operator. See also: ++
.'
Matrix transpose operator. For complex matrices, computes the transpose, _not_ the complex conjugate transpose. See also: ', transpose
.*
Element by element multiplication operator. See also: *, times
.**
Element by element power operator. If several complex results are possible, returns the one with smallest non-negative argument (angle). Use `realpow', `realsqrt', `cbrt', or `nthroot' if a real result is preferred. See also: **, ^, .^, power, realpow, realsqrt, cbrt, nthroot
...
Continuation marker. Joins current line with following line.
./
Element by element right division operator. See also: /, .\, rdivide, mrdivide
.\
Element by element left division operator. See also: \, ./, rdivide, mrdivide
.^
Element by element power operator. If several complex results are possible, returns the one with smallest non-negative argument (angle). Use `realpow', `realsqrt', `cbrt', or `nthroot' if a real result is preferred. See also: .**, ^, **, power, realpow, realsqrt, cbrt, nthroot
/
Test input validation !error delete () !error delete (1, 2) !error delete (struct ())
:
Select entire rows or columns of matrices.
;
Array row or command separator. See also:
<
'Less than' operator. See also: lt
<=
'Less than' or 'equals' operator. See also: le
=
Assignment operator.
==
Equality test operator. See also: eq
>
'Greater than' operator. See also: gt
>=
'Greater than' or 'equals' operator. See also: ge
[
Return list delimiter. See also: ]
\
Left division operator. See also: .\, /, ldivide, mldivide
]
Return list delimiter. See also: [
^
Power operator. This may return complex results for real inputs. Use `realsqrt', `cbrt', `nthroot', or `realroot' to obtain real results when possible. See also: power, **, .^, .**, realpow, realsqrt, cbrt, nthroot
|
Element by element logical 'or' operator. See also: ||, or
||
Logical 'or' (with short-circuit evaluation) operator. See also: |, or
~
Logical 'not' operator. See also: !, not
~=
Logical 'not equals' operator. See also: !=, ne

Keywords

break
Exit the innermost enclosing do, while or for loop. See also: do, while, for, parfor, continue
case
A case statement in an switch. Octave cases are exclusive and do not fall-through as do C-language cases. A switch statement must have at least one case. See `switch' for an example. See also: switch
catch
Begin the cleanup part of a try-catch block. See also: try
continue
Jump to the end of the innermost enclosing do, while or for loop. See also: do, while, for, parfor, break
do
Begin a do-until loop. This differs from a do-while loop in that the body of the loop is executed at least once. See also: while
else
Alternate action for an if block. See `if' for an example. See also: if
elseif
Alternate conditional test for an if block. See `if' for an example. See also: if
end
Mark the end of any `for', `if', `do', `while', or `function' block. See also: for, parfor, if, do, while, function
end_try_catch
Mark the end of an `try-catch' block. See also: try, catch
end_unwind_protect
Mark the end of an unwind_protect block. See also: unwind_protect
endfor
Mark the end of a for loop. See `for' for an example. See also: for
endfunction
Mark the end of a function. See also: function
endif
Mark the end of an if block. See `if' for an example. See also: if
endparfor
Mark the end of a parfor loop. See `parfor' for an example. See also: parfor
endswitch
Mark the end of a switch block. See `switch' for an example. See also: switch
endwhile
Mark the end of a while loop. See `while' for an example. See also: do, while
for
Begin a for loop. for i = 1:10 i endfor See also: do, parfor, while
function
Begin a function body with OUTPUTS as results and INPUTS as parameters. See also: return
global
Declare variables to have global scope. global X; if isempty (X) x = 1; endif See also: persistent
if
Begin an if block. x = 1; if (x == 1) disp ("one"); elseif (x == 2) disp ("two"); else disp ("not one or two"); endif See also: switch
otherwise
The default statement in a switch block (similar to else in an if block). See also: switch
parfor
Begin a for loop that may execute in parallel. parfor i = 1:10 i endparfor See also: for, do, while
persistent
Declare variables as persistent. A variable that has been declared persistent within a function will retain its contents in memory between subsequent calls to the same function. The difference between persistent variables and global variables is that persistent variables are local in scope to a particular function and are not visible elsewhere. See also: global
return
Return from a function. See also: function
static
This function has been deprecated in favor of persistent. See also: persistent
switch
Begin a switch block. yesno = "yes" switch yesno case {"Yes" "yes" "YES" "y" "Y"} value = 1; case {"No" "no" "NO" "n" "N"} value = 0; otherwise error ("invalid value"); endswitch See also: if, case, otherwise
try
Begin a try-catch block. If an error occurs within a try block, then the catch code will be run and execution will proceed after the catch block (though it is often recommended to use the lasterr function to re-throw the error after cleanup is completed). See also: catch, unwind_protect
until
End a do-until loop. See also: do
unwind_protect
Begin an unwind_protect block. If an error occurs within the first part of an unwind_protect block the commands within the unwind_protect_cleanup block are executed before the error is thrown. If an error is not thrown, then the unwind_protect_cleanup block is still executed (in other words, the unwind_protect_cleanup will be run with or without an error in the unwind_protect block). See also: unwind_protect_cleanup, try
unwind_protect_cleanup
Begin the cleanup section of an unwind_protect block. See also: unwind_protect
varargin
Pass an arbitrary number of arguments into a function. See also: varargout, nargin, isargout, nargout, nthargout
varargout
Pass an arbitrary number of arguments out of a function. See also: varargin, nargin, isargout, nargout, nthargout
while
Begin a while loop. See also: do