# MATPLOT¶

 Syntax MATPLOT array [{, | ;}] Location Math Package

This command takes a two-dimensional array and draws the points set out by the array (the first dimension identifies the number of points and the second the co-ordinates) to the default window used by LINE (normally #1). The array must be declared in the following way (an array which does not fall into this category will cause an error):

```DIM array (points,1)
```

points is the total number of points (less one) set out in the array, with array(p,0) the x-coordinate and array(p,1) the y- coordinate of point number p-1. If a comma (,) appears after the name of the array MATPLOT will connect each point with its successor by a line.

On the other hand, if a semicolon (;) appears after the name of the array, an additional line is drawn between the first point and the last point.

These lines are drawn using the QDOS line drawing routine and therefore suffer from the same problems as the LINE command. For those of you still uncertain of the possible uses of this command, a little hint: the addition of a semicolon to the the parameter will always enclose the set of lines which have been set out, thereby making this command ideal for creating all types of shapes (for example dodecahedrons)! MATPLOT supports INK, PAPER, OVER and FILL.

Example

The following fractal generator was written by John de Rivaz in SuperBASIC and optimised by Simon N. Goodwin. Originally, both the calculation and drawing was done in one loop which was a bit faster (10-20%) than the following version (this calculates all points in one loop and then uses MATPLOT to draw them quickly, creating a second internal loop). Another disadvantage compared to the original version is the increase in memory usage because all points have to be stored:

```100 MODE 4: WINDOW 512,256,0,0: PAPER 0: CLS
110 SCALE 20,-14,-10: iterations=10000
120 DIM pts(iterations-1,1): x=0: y=0
130 FOR loop=0 TO iterations-1
140   pts(loop,0)=x: pts(loop,1)=y
150   sy=0: IF x<0 THEN sy=-1: ELSE IF x THEN sy=1
160   xx=y-sy\*(ABS(x-.9))^.5: y=1.01-x: x=xx
170 END FOR loop
180 INK 7: MATPLOT pts
```

A nice modification of the above example would be to:

• Replace MODE 4 with MODE 8 in line 100;

• Delete line 180;

```180 REPeat loop
190 FOR n=1 TO 7
200 INK n
210 MATPLOT pts
220 END FOR n
230 END REPeat loop
```

It’s up to you to produce more variants!

NOTE

The output of MATPLOT cannot be redirected to any other window and specifically any program which uses MATPLOT (eg. the above example) cannot be compiled. So it is perhaps best to forget about MATPLOT.

CROSS-REFERENCE

MATPLOT_R draws the figure relative to the graphic cursor. POINT draws a single point to any screen, BLOCK can also be used to plot points, especially of variable size. PLOT, APOINT and POINT_ABS plot points in absolute co-ordinates, directly to screen memory, ignoring windows.