Previous: , Up: High-Level Plotting   [Contents][Index]

15.2.11 Test Plotting Functions

The functions sombrero and peaks provide a way to check that plotting is working. Typing either sombrero or peaks at the Octave prompt should display a three-dimensional plot.

sombrero ()
sombrero (n)
z = sombrero (…)
[x, y, z] = sombrero (…)

Plot the familiar 3-D sombrero function.

The function plotted is

z = sin (sqrt (x^2 + y^2)) / (sqrt (x^2 + y^2))

Called without a return argument, sombrero plots the surface of the above function over the meshgrid [-8,8] using surf.

If n is a scalar the plot is made with n grid lines. The default value for n is 41.

When called with output arguments, return the data for the function evaluated over the meshgrid. This can subsequently be plotted with surf (x, y, z).

peaks ()
peaks (n)
peaks (x, y)
z = peaks (…)
[x, y, z] = peaks (…)

Plot a function with lots of local maxima and minima.

The function has the form

f(x,y) = 3*(1-x)^2*exp(-x^2 - (y+1)^2) ...
- 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2) ...
- 1/3*exp(-(x+1)^2 - y^2)

Called without a return argument, peaks plots the surface of the above function using surf.

If n is a scalar, peaks plots the value of the above function on an n-by-n mesh over the range [-3,3]. The default value for n is 49.

If n is a vector, then it represents the grid values over which to calculate the function. If x and y are specified then the function value is calculated over the specified grid of vertices.

When called with output arguments, return the data for the function evaluated over the meshgrid. This can subsequently be plotted with surf (x, y, z).