Set the scale of the next graphic.
axis([xmin,xmax,ymin,ymax]) axis equal
The axis command, which should be placed before any other graphic 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.
Vertical bar plot.
bar(y) bar(x, y) bar(x, y, w) bar(..., kind) bar(..., kind, color)
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.
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
Horizontal bar plot.
barh(x) barh(y, x) barh(y, x, w) barh(..., kind) barh(..., kind, style)
barh plots a bar plot with horizontal bars. Please see bar for a description of its behavior and arguments.
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
Play music.
beep(freq) beep([freq, duration]) beep([freq, duration, volume])
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).
beep(440 * 2.^((0:12)'/12));
Clear the console (output) window.
clc
Clear the figure window.
clf
Discard the graphic output and display the text output window.
close
Level curves.
contour(z) contour(z, [xmin, xmax, ymin, ymax]) contour(z, [xmin, xmax, ymin, ymax], levels)
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.
u = -2 + (0:40) / 10; x = repmat(u, 41, 1); y = x'; z = exp(-((x-0.2).^2+(y+0.3).^2)) ... - exp(-((x+0.5).^2+(y-0.1).^2)) + 0.1 * x; scale('equal'); contour(z, [-1,1,-1,1]);
Close a database record.
dbcloserec(fd)
dbcloserec(fd) terminates the access to a record which was opened with dbnewrec or dbopenrec. The file descriptor fd cannot be used anymore.
Open an existing database record.
dbdelrec(dbName, index) dbdelrec(dbName, index, delBackup)
dbdelrec(dbName,index)(fd) deletes a record from the database identified by its name dbName. The record itself is identified by its index; the first record has index 0.
With a third argument delBackup, dbdelrec marks the record as deleted, so that the record will also be deleted from the backup the next time the Palm device is synchronized.
Close a database record.
dbdir dbdir('type') dbdir('type/creator') dblist = dbdir(...)
dbdir displays the list of databases with their types and creators. Types and creators are strings of four characters; the type characterizes the kind of data, and the creator identifies the application which owns the database. Without argument, databases with type 'appl', 'libr', 'neti', 'ovly', or 'panl' are not displayed.
To filter the databases which are displayed, a string argument may be provided. It contains the type, and optionally a slash character and the creator. The type or the creator can be replaced with the star character, which stands for any value.
With an output argument, dbdir returns a list of structures with fields name, type, and creator.
dbdir('DATA') AddressDB DATA/addr DatebookDB DATA/date MailDB DATA/mail MemoDB DATA/memo ConnectionDB DATA/modm NetworkDB DATA/netw ToDoDB DATA/todo db = dbdir('*/LyME'); dumpvar('db1', db{1}); db1 = struct('name','LyMELibDB', ... 'type','Lml ', ... 'creator','LyME');
Create a new database record.
fd = dbnewrec(dbName) (fd, index) = dbnewrec(dbName)
dbnewrec(dbName)(fd) adds a new record to the database identified by its name dbName. It returns a file descriptor which should be saved and used with functions such as fprintf and fwrite. Once the record is written, dbclose should be called to terminate the record creation.
The second output argument, if present, is set to the index of the record. The first record has index 0.
Creation of a new note for the Memo Pad application. Note that the record ends with a null byte.
fd = dbnewrec('MemoDB'); fprintf(fd, 'Sine between 0 and 90 deg\n'); for a = 0:15:90 fprintf(fd, 'sin(%d) = %g\n', a, sin(a)); end fwrite(fd, 0); dbcloserec(fd);
Number of records in a database.
n = dbnumrec(dbName)
dbnumrec(dbName)(fd) gives the number of records in the database identified by its name dbName.
Open an existing database record.
fd = dbopenrec(dbName, index)
dbopenrec(dbName,index)(fd) opens a record from the database identified by its name dbName. The record itself is identified by its index; the first record has index 0. dbopenrec returns a file descriptor which should be saved and used with functions such as fgets, fscanf and fread. Once the record has been read, dbclose should be called.
Reading of the first line of the first note for the Memo Pad application.
fd = dbopenrec('MemoDB', 0); line = fgetf(fd); dbcloserec(fd);
Graphic freeze.
hold on hold off
Command hold controls whether the graphic window is cleared before graphic 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.
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));
Generic plot with a logarithmic scale along x and y axis.
loglog(y) loglog(x, y) loglog(x, y, style)
Command loglog is similar to plot, except that the scale along both x and y axis is logarithmic.
plot, semilogx, semilogy, hold, clf
Put the handheld in low power mode.
pause(t)
pause(t) makes the handheld wait for t seconds in low-power mode.
Generic plot.
plot(y) plot(x, y) plot(x, y, style)
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' or 'o') or are linked with lines (style = '-'). The style may also specify the color:
Color | Character |
---|---|
black | k |
blue | b |
green | g |
cyan | c |
red | r |
magenta | m |
yellow | y |
white | w |
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).
Plot a sine in black and a cosine in light blue:
t = 0:0.1:2*pi; plot(t,[sin(t); cos(t)], 'kc');
semilogx, semilogy, loglog, polar, hold, clf
Polar plot.
polar(phi, r) polar(phi, r, style)
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.
See the description of plot for more information about the third argument.
phi = 2*pi*(0:100)/100; plot(phi, 2+cos(5*phi), 'r');
Generic plot with a logarithmic scale along x axis.
semilogx(y) semilogx(x, y) semilogx(x, y, style)
Command semilogx is similar to plot, except that the scale along the x axis is logarithmic.
plot, semilogy, loglog, hold, clf
Generic plot with a logarithmic scale along y axis.
semilogy(y) semilogy(x, y) semilogy(x, y, style)
Command semilogy is similar to plot, except that the scale along the y axis is logarithmic.
plot, semilogx, loglog, hold, clf