Node:Terminal Output, Next:Terminal Input, Up:Basic Input and Output
Since Octave normally prints the value of an expression as soon as it
has been evaluated, the simplest of all I/O functions is a simple
expression. For example, the following expression will display the
value of pi
pi -| pi = 3.1416
This works well as long as it is acceptable to have the name of the
variable (or ans
) printed along with the value. To print the
value of a variable without printing its name, use the function
disp
.
The format
command offers some control over the way Octave prints
values with disp
and through the normal echoing mechanism.
ans | Built-in Variable |
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 |
fdisp (fid, x) | Built-in Function |
Display the value of x on the stream fid. For example,
fdisp (stdout, "The value of pi is:"), fdisp (stdout, pi) -| the value of pi is: -| 3.1416 Note that the output from |
disp (x) | Built-in Function |
Display the value of x. For example,
disp ("The value of pi is:"), disp (pi) -| the value of pi is: -| 3.1416 Note that the output from If an output value is requested, |
format options | Command |
Control the format of the output produced by disp and Octave's
normal echoing mechanism. Valid options are listed in the following
table.
By default, Octave will try to print numbers with at least 5 significant figures within a field that is a maximum of 10 characters wide. If Octave is unable to format a matrix so that columns line up on the
decimal point and all the numbers fit within the maximum field width,
it switches to an If |
print_answer_id_name | Built-in Variable |
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.
|