XFuns are plug-in modules that can be used to extend MathPad's capabilities. Several XFuns are included with the MathPad distribution. More are available at http://pubpages.unh.edu/~mwidholm/MathPad

To add an XFun, drag the file from the "XFuns" folder the into MathPad's "Active XFuns" folder. If MathPad is already running, you must quit and re-launch it to see the new XFun.

Installed XFuns will be added to the Functions menu and typically also add items to the Help menu to show how to use the function.

Programers interested in writing their own XFuns can download an XFun kit. It contains documentation, interface routines and C source code for several example XFuns. CodeWarrior projects are included but other development systems should be able to create Xfuns as well.

**Ctab**

Set up a custom color table for image plots.

-- ColorTable(RGBarray)

**fft**

Discrete Fourier transform routines

-- fft(C) transform of a complex array.

-- invfft(C) inverse transform.

-- rfft(R) transform of a real array.

-- pwrspec(R) power spectrum estimate of a real array.

**gamma**

Gamma and error functions

-- gamma(n)

-- lgamma(n)

-- erf(n)

-- erfc(n)

**histogram**

Accumulate a histogram of the values in an array

-- histogram(array,lo,hi,nbins)

**histo2D**

Accumulate a 2D histogram

-- histo2D(xarray,xlo,xhi,xbins,yarray,ylo,yhi,ybins)

**hyperbolic**

Hyperbolic trig functions

-- acosh(n)

-- asinh(n)

-- atanh(n)

-- cosh(n)

-- sinh(n)

-- tanh(n)

**imageRGB**

Allow direct specification of image color components

-- imageRGB(rgbarray,pixsize)

**linfit**

Fit data to a straight line using linear regression

-- linfit(XYpoints)

**max**

Utility functions for 1D arrays

-- max(array)

-- min(array)

-- maxindex(array)

-- minindex(array)

-- ave(array)

**progressbar**

Can be called repeatedly during a long calculation to display a window with a progress bar and an estimate for time remaining.

-- progressbar(percent)

**QTmovie**

Save a sequence of plots as a QuickTime movie.

-- movie(fname,nframes)

**readgray**

Read a PICT file as an array of grayscale values.

-- readgray(fname,width,height)

**readsnd**

Read and write sound files to and from a data array

-- readsnd("fname")

-- writesnd("fname",samples,rate,bits)

-- playsnd(samples,rate,bits)

**showPICT**

Read a PICT file and displays it as a data plot overlay

-- showPICT(fname,left,bot,width,ht)

**sizeaxis**

Change the plot window size to get a specific data axis size or aspect ratio. Can be used to force a square data display coordinate system.

-- sizeaxis(xpix,ypix)

**sliders**

Allow values to be controlled by slider bars

-- slider(name,min,max)

**SVD**

Linear algebra tools using singular value decomposition. These XFuns are considerably faster and more accurate than using the det() function.

-- solve(A,B) solves a system of linear equations A*X = B

-- invert(A) finds the inverse of matrix A

-- SVD(A) returns the decomposition arrays

**ticks**

Return the current system tick count for timing comparisons

-- ticks(0)

**viewsurf**

Display a projection of a 3D surface

-- viewsurf(zgrid,plotflag)