The first part of this file describes how to create MEX files on plane,
sine, or cosine (or any other unix system on which Matlab version 6 is
available) for 8 Nonlinear Systems Toolbox functions, listed below.

The second part describes how to compile MEX files on a Macintosh,

----------------------------------------------------------------------

Creating MEX files on unix  (12/6/2001)
---------------------------------------

The 8 functions in question are:

     [h,nh]=cmp(f,nf,df,g,ng,dg,d)
     [h,nh]=dd(f,nf,df,g,ng,dg,d)
     [h,nh]=jcbn(f,nf,df,nj,d)
     [h,nh]=mply(f,nf,df,g,ng,dg,d)
     z=mon(x,n,d)
     c=chuze(n,k)
     m=crd(n,d)
     m=crdsum(n,d0,d1) or m=crdsum(n,[d0 d1])

First create a directory for the files that will be needed.  You can give
this directory any name that you want; in this description I'll assume
that it's called "NST".  To create the directory, type the unix command
"mkdir NST".

Save the uuencoded tar archive in NST; call it "nst.tar.uu".  (Exactly how
you'll put it there depends on what email program you're using; let me
know if you have any trouble.)

Type "cd NST" to make NST your working directory.

Type "uudecode nst.tar.uu".  This will create the file "nst.tar", which
is the tar archive of the source files.

Type "tar -x <nst.tar".  This extracts the source files from the archive.
If you now type "ls", you should see the following list of files:

    addprod.c      compose.c   jcbn.c        nst.tar         walkredmonom.c
    addprodcplx.c  crd.c       Makefile      nst.tar.uu
    choose.c       crdsum.c    mexdefines.h  sqz.ext.c
    chuze.c        dd.c        mon.c         sqz.ext.cplx.c
    cmp.c          jacobian.c  mply.c        walkmonom.c

Type "make all".  This causes commands in the file "Makefile" to be
executed, which will compile and link the c programs, creating the MEX
files.  A bunch of cryptic messages will appear on your screen.  After a
while, they'll stop and you'll get a unix prompt.  Type "ls" to list the
files in your directory; in addition to the source files listed above,
there should be 8 new files, whose names are similar to these (The suffix
may be different on some systems.):

        chuze.mexglx    cmp.mexglx      crd.mexglx      crdsum.mexglx
        dd.mexglx       jcbn.mexglx     mon.mexglx      mply.mexglx

At this point, you can run MATLAB by typing "matlab".  The functions
listed above should be available.  As a test, try typing "chuze(6,2)".
MATLAB should give the answer 15.

----------------------------------------------------------------------

How to compile MEX files on iMac   (12/13/2001)
-----------------------------------------------

I had great difficulty doing this, finally succeeding mostly by accident,
so I'm writing down the steps to make it work.  I don't understand why they
work and all the other things I tried didn't, and I don't know how to modify
them for other versions of Matlab or other C compilers.

Install Matlab 5.2 and CodeWarrior 6.0.  Use "minimum install" for CW;
otherwise use defaults for everything.

Edit the file "harddisk:MATLAB 5:extern:src:mexcppinit.cpp":  Change
"InitBlockPtr" to "int" twice and save the file.

Run Matlab.

    Type "mex -setup".  Choose "Metroworks CodeWarrior ProC".

    Click on the Path Browser icon in the command window.  Then click on
        "Default Path" and "Save".

    Open a file in the directory containing the source files.  Then close it.
        (This ensures that Matlab will find the source files when you give the
        mex command below.  There's probably a "change directory" command
        that does the same thing.)

    Give mex commands like this:

        mex OPTIMFLAGS='' chuze.c choose.c

    (This compiles the function chuze(m,n), which depends on functions in
    the file choose.c.  Setting OPTIMFLAGS to an empty string prevents the
    compiler from trying to do optimization.  Of course optimization would be
    nice, but attempting it causes an error message.)

    After a while, a window will appear asking if you want to convert the
    project.  Hit return.

    You'll receive a warning "Link Warning : ignored 'qd' (data) in
    MSL RuntimePPC.Lib Previously defined in MATLAB".  Ignore it.

    Several files will be created:  chuze.mex,  chuze.prefix,  chuze.\mu,
    and a directory  "chuze Data".  You can delete all but chuze.mex.

    Now you can give commands like "chuze(6,2)" from Matlab.

----------------------------------------------------------------------
