Maxima by Example, Ch. 2, Plots, Files, Read, Write, and Fit
Ted Woollett
Chapter 2 has been revised to include a large section on working with
files from within Maxima. The new software file mfiles.mac includes many
useful file manipulation functions. The small file mfiles1.lisp is loaded
in by mfiles.mac.
Since Jan. 19, 2012, all updates reflect the necessity of using the complete file path (in ver. 5.26.0 thru 5.31) for all
of the "file name slots" in the file manipulation functions defined in mfiles.mac.
To save typing, one can define (in your maxima-init.mac file) a function mkp (make path)
which makes use of a global parameter bpath which is a string which provides the base
of the path to your work folder. One can then use mkp("myfile1.txt") instead of
"c:/work2/myfile1.txt" as an argument to a file name slot. This is discussed at length
in the introduction to the File section of chapter two.
This chapter has many examples of the use of plot2d. Before you read and try out the examples,
run the appropriate plot2dtest file available above the Ch. 1 section. You may need to use one of
the draw2d substitutes, depending on the version of Maxima you are using.
- --mbe2plotfit.pdf : Jan. 6, 2014, Maxima 5.31.2, 40 pages
- --mbe2plotfit.tex : Jan. 6, 2014, Latex code file
- --mbe2toc.txt : Detailed table of contents, Jan. 6, 2014
- --mbe2code.txt : Code file: Jan. 6, 2014, Maxima 5.31.2
- --qplot.mac : Maxima code for quick plots, Oct. 3, 2011, Maxima 5.25.1
- --mfiles.mac : Maxima code for file work, Jan. 19, 2012, Maxima 5.28.0
- --mfiles1.lisp : Lisp code loaded by mfiles.mac, Oct. 3, 2011, Maxima 5.25.1
- --coffee.dat : Coffee cooling tab separated data file: July, 13, 2009
Chapter 2 Topics
Introduction to plot2d
- First Steps with plot2d
- Parametric Plots
- Line Width and Color Controls
- Discrete Data Plots: Point Size, Color, and Type Control
- Plot of a Discontinuous Function
- Using qplot for Quick Plots of One or More Functions
- Multiple Plots Using the Embedded Option
Working with Files Using the Package mfiles.mac
- file_search, probe_file, ls, and dir
- ftype, file_length, file_info
- print_file, print_lines
- rename_file, delete_file, copy_file, file_convert, ftext_replace
- Break file lines with pbreak(), email reply with reply_to
- Search File with search_file
- Search Multiple files with search_mfiles
- read_data, read_text, write_data, with_stdout
Least Squares Fit to Experimental Data
- Syntax of lsquares_estimates
- Coffee Cooling Model
- Experiment Data for Coffee Cooling
- Least Squares Fit of Coffee Cooling Data
The new function read_data is designed to work correctly with unix, mac,
and windows type text files.
read_data uses the new function read_line which is a replacement for the
current Maxima function readline.
The new function print_file correctly reads unix, mac, and windows
files and is a replacement for the current Maxima function printfile.