Go to the first, previous, next, last section, table of contents.


Built-in Variables

Most Octave variables are available for you to use for your own purposes; they never change except when your program assigns values to them, and never affect anything except when your program examines them.

A number of variables have special built-in meanings. Some of them, like pi and eps provide useful predefined constant values. Others, like do_fortran_indexing and page_screen_output are examined automatically by Octave, so that you can to tell Octave how to do certain things. There are also two special variables, ans and PWD, that are set automatically and carry information from the internal workings of Octave to your program.

This chapter documents the built-in variables of Octave that don't seem to belong anywhere else. Many more of Octave's built-in variables are documented in the chapters that describe functions that use them, or are affected by their values.

Miscellaneous Built-in Variables

This section describes the variables that you can use to customize Octave's behavior.

Normally, preferences are set in the file `~/.octaverc', so that you can customize your environment in the same way each time you use Octave without having to remember and retype all the necessary commands. See section Startup Files for more information.

Built-in Variable: OCTAVE_VERSION
The version number of Octave, as a string.

Built-in Variable: PS1
The primary prompt string. When executing interactively, Octave displays the primary prompt PS1 when it is ready to read a command. Octave allows the prompt to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:

`\t'
The time.
`\d'
The date.
`\n'
Begins a new line by printing the equivalent of a carriage return followed by a line feed.
`\s'
The name of the program (usually just octave).
`\w'
The current working directory.
`\W'
The basename of the current working directory.
`\u'
The username of the current user.
`\h'
The hostname.
`\H'
The hostname, up to the first `.'.
`\#'
The command number of this command, counting from when Octave starts.
`\!'
The history number of this command. This differs from `\#' by the number of commands in the history list when Octave starts.
`\$'
If the effective UID is 0, a #, otherwise a $.
`\nnn'
The character whose character code in octal is `nnn'.
`\\'
A backslash.

The default value of PS1 is "\s:\#> ". To change it, use a command like

octave:13> PS1 = "\\u@\\H> "

which will result in the prompt `boris@kremvax> ' for the user `boris' logged in on the host `kremvax.kgb.su'. Note that two backslashes are required to enter a backslash into a string. See section String Constants.

Built-in Variable: PS2
The secondary prompt string, which is printed when Octave is expecting additional input to complete a command. For example, when defining a function over several lines, Octave will print the value of PS1 at the beginning of each line after the first. Octave allows PS2 to be customized in the same way as PS1. The default value of PS2 is "> ".

Built-in Variable: PS4
If Octave is invoked with the --echo-input option, the value of PS4 is printed before each line of input that is echoed. Octave allows PS4 to be customized in the same way as PS1. The default value of PS4 is "+ ". See section Invoking Octave, for a description of --echo-input.

Built-in Variable: ans
This variable holds the most recently computed result that was not explicitly assigned to a variable. For example, after the expression

3^2 + 4^2

is evaluated, the value of ans is `25'.

Built-in Variable: completion_append_char
The value of completion_append_char is used as the character to append to successful command-line completion attempts. The default value is " " (a single space).

Built-in Variable: ok_to_lose_imaginary_part
If the value of ok_to_lose_imaginary_part is nonzero, implicit conversions of complex numbers to real numbers are allowed (for example, by fsolve). If the value is "warn", the conversion is allowed, but a warning is printed. Otherwise, an error message is printed and control is returned to the top level. The default value is "warn".

Built-in Variable: print_answer_id_name
If the value of print_answer_id_name is nonzero, variable names are printed along with the result. Otherwise, only the result values are printed. The default value is 1.

Built-in Variable: propagate_empty_matrices
If the value of propagate_empty_matrices is nonzero, functions like inverse and svd will return an empty matrix if they are given one as an argument. The default value is 1. See section Empty Matrices.

Built-in Variable: treat_neg_dim_as_zero
If the value of treat_neg_dim_as_zero is nonzero, expressions like

eye (-1)

produce an empty matrix (i.e., row and column dimensions are zero). Otherwise, an error message is printed and control is returned to the top level. The default value is 0.

Summary of Preference Variables

Here is a summary of all of Octave's preference variables and their default values. In the following table OCT_HOME stands for the root directory where Octave is installed, VERSION stands for the Octave version number, and SYS stands for the type of system for which Octave was compiled (for example, alpha-dec-osf3.2).

EDITOR                  "vi"
EXEC_PATH               ":$PATH"
INFO_FILE               "OCT_HOME/info/octave.info"
INFO_PROGRAM            "OCT_HOME/libexec/octave/VERSION/exec/SYS/info"
LOADPATH                ".:OCT_HOME/lib/VERSION"
PAGER                   "less", or "more"
PS1                     "\s:\#> "
PS2                     "> "
PS4                     "+ "
automatic_replot        0

beep_on_error                 0
completion_append_char        " "
default_return_value          []
do_fortran_indexing           0
define_all_return_values      0
empty_list_elements_ok        "warn"
gnuplot_binary                "gnuplot"
history_file                  "~/.octave_hist"
history_size                  1024
ignore_function_time_stamp    "system"

implicit_str_to_num_ok        0
ok_to_lose_imaginary_part     "warn"
output_max_field_width        10
output_precision              5
page_screen_output            1
prefer_column_vectors         0
prefer_zero_one_indexing      0
print_answer_id_name          1
print_empty_dimensions        1
resize_on_range_error         1

return_last_computed_value    0
save_precision                17
saving_history                1
silent_functions              0
split_long_rows               1
struct_levels_to_print        2
suppress_verbose_help_message 1
treat_neg_dim_as_zero         0
warn_assign_as_truth_value    1
warn_comma_in_global_decl     1

warn_divide_by_zero           1
warn_function_name_clash      1
whitespace_in_literal_matrix  ""

The following variables may be set from the environment or by a command line option.

Variable        Environment Variable    Option 
--------        --------------------    ------
EDITOR          EDITOR
EXEC_PATH       OCTAVE_EXEC_PATH        --exec-path PATH    
LOADPATH        OCTAVE_PATH             --path PATH
INFO_FILE       OCTAVE_INFO_FILE        --info-file FILE
INFO_PROGRAM    OCTAVE_INFO_PROGRAM     --info-program PROGRAM
history_size    OCTAVE_HISTSIZE
history_file    OCTAVE_HISTFILE


Go to the first, previous, next, last section, table of contents.