lec8.mw

MCS 320 L-8 Friday 9 September 2005

> restart;

1. Maple Input and Output

> p := x^2 + 3*x -9;

> lprint(p); # same as convert to string

> printlevel := 5; # prints more information

> solve(p,x);

2. Exporting Plots

3. Reading and Writing Files

> printlevel := 1;

> sols := solve(p,x);

To save the polynomials and the solutions to file, we can use save

> save p,sols,"H:\\data";

The file "data" on our H drive contains the p and sols as we would type it in in a Maple worksheet.

> p := 'p'; sols := 'sols'; # clear p and sols

> read "H:\\data";

With "writeto" and "appendto" we can write everything which appears on screen to a file.  This is mainly useful for running procedures in batch and if we are running Maple in command line mode.

4. Importing and Exporting Data

> m := matrix(4,3,(i,j) -> 1/(i+j-1));

To save this data in a format useful also to other programs, we can use the writedata.

> data := map(evalf[20],m); # convert to 20 decimal places

> writedata(terminal,data,float);

> writedata("H:\\matrixdata",data,float);

> data := 'data';

> data := readdata("H:\\matrixdata",3);

The result of the readdata is already stored as a variable of type listlist;

> matrix(4,3,data);

5. Low-Level I/O