LyME-specific Functions

axis

Set the scale of the next graphics.

Syntax

axis([xmin,xmax,ymin,ymax])
axis equal
limits = axis

Description

With an input argument, the axis command, which should be placed before any other graphical command, sets the scale and scale options. The parameter is either a vector of 4 elements which sets the limits of the plot for both x and y axis, or the string 'equal' to make the scale equal in both directions so that circles are really displayed as circles and not ellipses.

With an output argument, axis gives the current limits of the plot in a row vector [xmin,xmax,ymin,ymax].

See also

clf, hold

bar

Vertical bar plot.

Syntax

bar(y)
bar(x, y)
bar(x, y, w)
bar(..., kind)
bar(..., kind, color)

Description

bar(x,y) plots the columns of y as vertical bars centered around the corresponding value in x. If x is not specified, its default value is 1:size(y,2).

bar(x,y,w), where w is scalar, specifies the relative width of each bar with respect to the horizontal distance between the bars; with values smaller than 1, bars are separated with a gap, while with values larger than 1, bars overlap. If w is a vector of two components [w1,w2], w1 corresponds to the relative width of each bar in a group (columns of y), and w2 to the relative width of each group. Default values, used if w is missing or is the empty matrix [], is 0.8 for both w1 and w2.

bar(...,kind), where kind is a string, specifies the kind of bar plot. The following values are recognized:

'grouped'Columns of y are grouped horizontally (default)
'stacked'Columns of y are stacked vertically
'interval'Same as grouped, except that bars have min and max values

With 'interval', intervals are defined by two consecutive rows of y, which must have an even number of rows.

The optional argument color is a string made of one or several color characters:

'k'black
'w'white with a black frame

First color is applied to first row of y, second color to second row, and so on; if there are less colors than rows, colors are recycled.

Examples

bar([2,4,3,6;3,5,4,1]);                       % simple bar plot
bar(1:4, magic(4), [], 'stacked');            % stacked bar plot
bar(1:4, [2,4,3,1;5,6,4,6], [], 'interval');  % interval plot

See also

barh, plot

barh

Horizontal bar plot.

Syntax

barh(x)
barh(y, x)
barh(y, x, w)
barh(..., kind)
barh(..., kind, style)

Description

barh plots a bar plot with horizontal bars. Please see bar for a description of its behavior and arguments.

Examples

barh([2,4,3,6;3,5,4,1]);                       % simple bar plot
barh(1:4, magic(4), [], 'stacked');            % stacked bar plot
barh(1:4, [2,4,3,1;5,6,4,6], [], 'interval');  % interval plot

See also

bar, plot

beep

Play music.

Syntax

beep(freq)
beep([freq, duration])
beep([freq, duration, volume])

Description

The beep command plays one or several sounds. Argument is a m-by-n matrix, with n between 1 and 3; first column is the frequency in Hertz, second column is duration in seconds (default 0.1), and third column is volume between 0 and 1 (default 1).

Example

beep(440 * 2.^((0:12)'/12));

See also

audioplay, pause

clc

Clear the console (output) window.

Syntax

clc
clc(fd)

clc (clear console) clears the contents of the text output panel.

clc(fd) clears the contents of the text output associated with file descriptor fd.

See also

clf, close

clf

Clear the figure window.

Syntax

clf

See also

close, clc, hold, plot

close

Discard the graphics output and display the text output window.

Syntax

close

See also

clf, clc

contour

Level curves.

Syntax

contour(z)
contour(z, [xmin, xmax, ymin, ymax])
contour(z, [xmin, xmax, ymin, ymax], levels)

Description

contour(z) plots seven contour lines corresponding to the surface whose samples at equidistant points 1:size(z,2) in the x direction and 1:size(z,1) on the y direction are given by z. Contour lines are at equidistant levels. With a second non-empty argument [xmin, xmax, ymin, ymax], the samples are at equidistant points between xmin and xmax in the x direction and between ymin and ymax in the y direction. The optional third argument levels, if non-empty, gives the number of contour lines if it is a scalar or the levels themselves if it is a vector.

Example

A function is evaluated over a grid of two variables x and y, and is drawn with contour:

(x, y) = meshgrid(-2 + (0:40) / 10);
z = exp(-((x-0.2).^2+(y+0.3).^2)) ...
      - exp(-((x+0.5).^2+(y-0.1).^2)) + 0.1 * x;
axis equal;
contour(z, [-1,1,-1,1]);

See also

plot

fplot

Function plot.

Syntax

fplot(fun)
fplot(fun, limits)
fplot(fun, limits, style)
fplot(fun, limits, style, p1, p2, ...)

Description

Command fplot(fun,limits) plots function fun, specified by its name as a string, a function reference, or an inline function. The function is plotted for x between limit(1) and limit(2); the default limits are [-5,5].

The style of the plot can be specified with a third argument (see plot for details). Remaining input arguments of fplot, if any, are given as additional input arguments to function fun. They permit to parameterize the function. For example fplot('fun',[0,10],'',2,5) calls fun as y=fun(x,2,5) and displays its value for x between 0 and 10.

Examples

Plot a sine:

fplot(@sin);

Plot (x+0.3)^2+a*exp(-3*x^2) in red for x between -2 and 3 with a=7.2 and an identifier of 1:

fun = inline('function y=f(x,a); y=(x+0.3)^2+a*exp(-3*x^2);');
fplot(fun, [-2,3], 'r', 7.2);

See also

plot, hold, clf, inline, operator @

hold

Graphic freeze.

Syntax

hold on
hold off

Description

Command hold controls whether the graphics window is cleared before graphical commands such as plot and text display new elements. hold on suspends the auto-clear feature, and hold off resumes it. In any case, clf always resumes it.

Example

t = 0:0.1:2*pi;
plot(t, sin(t));
hold on;
plot(t, cos(t));
hold off;
pause(3);
plot(t, sin(t).*cos(t));

See also

plot, clf

image

Image plot.

Syntax

image(A)

Description

image(A) displays array A as an image. A is an array of two dimensions for grayscale images or three dimensions for RGB images, with size(A,3)==3. image accepts different types of data: double arrays must contain numbers between 0 for black and 1 for maximum intensity; uint8 arrays contain numbers between 0 for black and 255 for maximum intensity; and logical arrays contain false for black and true for maximum intensity. Function map2int is useful for converting double values in other ranges.

The image is displayed as a low density bitmap, centered in the graphics area. The first value in the array corresponds to the top left corner.

Availability

image requires Palm OS 4.0 or higher.

Example

x = meshgrid(-2:0.1:2);    % coord for x (y is x.')
A = cos(x.^2 + x.'.^2);    % cos(r^2), element-wise
image(map2int(A, -1, 1));  % double [-1,1] to uint8

See also

plot, clf, map2int

loglog

Generic plot with a logarithmic scale along x and y axis.

Syntax

loglog(y)
loglog(x, y)
loglog(x, y, style)

Description

Command loglog is similar to plot, except that the scale along both x and y axis is logarithmic.

See also

plot, semilogx, semilogy, hold, clf

pause

Put the handheld in low power mode.

Syntax

pause(t)

Description

pause(t) makes the handheld wait for t seconds in low-power mode.

plot

Generic plot.

Syntax

plot(y)
plot(x, y)
plot(x, y, style)

Description

Command plot displays graphical data. The data are given as two vectors of coordinates x and y. Depending on the style, the points are displayed as individual marks (style = 'x', 'o', or '.') or are linked with lines (style = '-'). The style may also specify the color:

ColorCharacter
blackk
blueb
greeng
cyanc
redr
magentam
yellowy
whitew

The default style is '-'.

If x and y are matrices, each row is considered as a separate line or set of marks; if only one of them is a matrix, the other one, a vector, is reused for each line. The style string may contain several styles which are used for each line, and recycled if necessary.

The first argument x may be omitted; its default value is 1:size(y,2).

Example

Plot a sine in black and a cosine in light blue:

t = 0:0.1:2*pi;
plot(t,[sin(t); cos(t)], 'kc');

See also

semilogx, semilogy, loglog, polar, fplot, hold, clf

polar

Polar plot.

Syntax

polar(phi, r)
polar(phi, r, style)

Description

Command polar displays graphical data in polar coordinates. The data are given as two vectors of polar coordinates phi and r; their corresponding Cartesian coordinates are x=r*cos(phi) and y=r*sin(phi). Several polar plots may be combined with hold; however, other kinds of plots should not be mixed.

If phi and r are matrices, each row is considered as a separate line or set of marks. Unlike plot, both matrices must have the same size.

See the description of plot for more information about the third argument.

Example

phi = 2*pi*(0:100)/100;
polar(phi, 2+cos(5*phi), 'r');

See also

plot, hold, clf

semilogx

Generic plot with a logarithmic scale along x axis.

Syntax

semilogx(y)
semilogx(x, y)
semilogx(x, y, style)

Description

Command semilogx is similar to plot, except that the scale along the x axis is logarithmic.

See also

plot, semilogy, loglog, hold, clf

semilogy

Generic plot with a logarithmic scale along y axis.

Syntax

semilogy(y)
semilogy(x, y)
semilogy(x, y, style)

Description

Command semilogy is similar to plot, except that the scale along the y axis is logarithmic.

See also

plot, semilogx, loglog, hold, clf

text

Display formatted text in a figure.

Syntax

text(x, y, string)

Description

text displays a string centered at the specified position. Function sprintf can be used to create a string and display numbers.

Example

The following code displays the string (1.2,3.7) centered around these coordinates.

x = 1.2;
y = 3.7;
text(x, y, sprintf('(%.1f,%.1f)', x, y));

See also

disp, fprintf, sprintf


Copyright 1998-2007, Calerga.
All rights reserved.