# Physics307L F09:People/Mondragon/Poisson/Programming/CommandReference

**Command reference** taken from the documentation for Octave 3.0
Copyright © 1996, 1997, 1999, 2000, 2001, 2002, 2005, 2006, 2007 John W. Eaton.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.

## diary

**diary** *options*

- Create a list of all commands and the output they produce, mixed together just as you see them on your terminal. Valid options are:

- on
- Start recording your session in a file called ‘diary’ in your current working directory.

- off
- Stop recording your session in the diary file.

- file
- Record your session in the file named file.

- Without any arguments, diary toggles the current diary state.

## poissrnd

**poissrnd** (*lambda*, *r*, *c*)

- Return an
*r*by*c*matrix of random samples from the Poisson distribution with parameter*lambda*, which must be a scalar or of size*r*by*c*.

- If
*r*and*c*are omitted, the size of the result matrix is the size of*lambda*.

## values

**values** (*x*)

- Return the different values in a column vector, arranged in ascending order.

- As an example, values([1, 2, 3, 1]) returns the vector [1, 2, 3].

## range

**range** (*x*, *dim*)

- If
*x*is a vector, return the range, i.e., the difference between the maximum and the minimum, of the input data.

- If
*x*is a matrix, do the above for each column of*x*.

- If the optional argument
*dim*is supplied, work along dimension*dim*.

## max

**max** (*x*, *y*, *dim*)

[*w*, *iw*] = **max** (*x*)

- For a vector argument, return the maximum value. For a matrix argument, return the maximum value from each column, as a row vector, or over the dimension
*dim*if defined. For two matrices (or a matrix and scalar), return the pair-wise maximum. Thus,

max (max (x))

- returns the largest element of
*x*, and

max (2:5, pi) 3.1416 3.1416 4.0000 5.0000

- compares each element of the range
`2:5`with`pi`, and returns a row vector of the maximum values.

- For complex arguments, the magnitude of the elements are used for comparison.

- If called with one input and two output arguments, max also returns the first index of the maximum value(s). Thus,

[x, ix] = max ([1, 3, 5, 2, 5]) x = 5 ix = 3

## min

**min** (*x*, *y*, *dim*)

[*w*, *iw*] = **min** (*x*)

- For a vector argument, return the minimum value. For a matrix argument, return the minimum value from each column, as a row vector, or over the dimension
*dim*if defined. For two matrices (or a matrix and scalar), return the pair-wise minimum. Thus,

min (min (x))

- returns the smallest element of
*x*, and

min (2:5, pi) 2.0000 3.0000 3.1416 3.1416

- compares each element of the range
`2:5`with`pi`, and returns a row vector of the minimum values.

- For complex arguments, the magnitude of the elements are used for comparison.

- If called with one input and two output arguments, min also returns the first index of the minimum value(s). Thus,

[x, ix] = min ([1, 3, 0, 2, 5]) x = 0 ix = 3

## hist

**hist** (*y*, *x*)

- Produce histogram counts or plots.

- With one vector input argument, plot a histogram of the values with 10 bins. The range of the histogram bins is determined by the range of the data.

- Given a second scalar argument, use that as the number of bins.

- Given a second vector argument, use that as the centers of the bins, with the width of the bins determined from the adjacent values in the vector.

- Extreme values are lumped in the first and last bins.

- With two output arguments, produce the values
*nn*and*xx*such that bar (*xx*,*nn*) will plot the histogram.

## bar

**bar** (*x*, *y*)

- Given two vectors of x-y data, bar produces a bar graph.

- If only one argument is given, it is taken as a vector of y-values and the x coordinates are taken to be the indices of the elements.

- If two output arguments are specified, the data are generated but not plotted. For example,

bar (x, y);

- and

[xb, yb] = bar (x, y); plot (xb, yb);

- are equivalent.

## plot

**plot** (*args*)

- This function produces two-dimensional plots. Many different combinations of arguments are possible. The simplest form is

plot (y)

- where the argument is taken as the set of
*y*coordinates and the*x*coordinates are taken to be the indices of the elements, starting with 1.

- If more than one argument is given, they are interpreted as

plot (x, y, fmt ...)

- where
*y*and*fmt*are optional, and any number of argument sets may appear. The*x*and*y*values are interpreted as follows:

- If a single data argument is supplied, it is taken as the set of
*y*coordinates and the*x*coordinates are taken to be the indices of the elements, starting with 1.

- If a single data argument is supplied, it is taken as the set of

- If the first argument is a vector and the second is a matrix, then the vector is plotted versus the columns (or rows) of the matrix. (using whichever combination matches, with columns tried first.)

- If the first argument is a matrix and the second is a vector, the the columns (or rows) of the matrix are plotted versus the vector. (using whichever combination matches, with columns tried first.)

- If both arguments are vectors, the elements of
*y*are plotted versus the elements of*x*.

- If both arguments are vectors, the elements of

- If both arguments are matrices, the columns of
*y*are plotted versus the columns of*x*. In this case, both matrices must have the same number of rows and columns and no attempt is made to transpose the arguments to make the number of rows match.

- If both arguments are matrices, the columns of

- If both arguments are scalars, a single point is plotted.

- The fmt argument, if present is interpreted as follows. If fmt is missing, the default gnuplot line style is assumed.

`-'

- Set lines plot style (default).

`.'

- Set dots plot style.

`@'

- Set points plot style.

`-@'

- Set linespoints plot style.

`^'

- Set impulses plot style.

`L'

- Set steps plot style.

`#'

- Set boxes plot style.

`~'

- Set errorbars plot style.

`#~'

- Set boxerrorbars plot style.

`n'

- Interpreted as the plot color if
*n*is an integer in the range 1 to 6.

- Interpreted as the plot color if

`nm'

- If
*nm*is a two digit integer and*m*is an integer in the range 1 to 6,*m*is interpreted as the point style. This is only valid in combination with the @ or -@ specifiers.

- If

`c'

- If c is one of
`"r"`,`"g"`,`"b"`,`"m"`,`"c"`, or`"w"`, it is interpreted as the plot color (red, green, blue, magenta, cyan, or white).

- If c is one of

`+' `*' `o' `x'

- Used in combination with the points or linespoints styles, set the point style.

- The color line styles have the following meanings on terminals that support color.

Number Gnuplot colors (lines)points style 1 red * 2 green + 3 blue o 4 magenta x 5 cyan house 6 brown there exists

- Here are some plot examples:

plot (x, y, "@12", x, y2, x, y3, "4", x, y4, "+")

- This command will plot
*y*with points of type 2 (displayed as``+'`) and color 1 (red),*y2*with lines,*y3*with lines of color 4 (magenta) and*y4*with points displayed as``+'`.

plot (b, "*")

- This command will plot the data in the variable
*b*will be plotted with points displayed as``*'`.