Getting started

Spring, 2003

Back to the main course home page.

This should help you get started using C or C++ and Matlab together for computing and visualization.

**Environment:** You need access to C/C++ and Matlab. All registered students
may use the math department network of SUN workstations that run a version of the
UNIX operating system and have installed both the SUN and GNU C/C++ compilers
complete with performance tools and a window based debugger. If you choose to
work elsewhere, a personal computer or computer at work are common choices, you
must have a C/C++ compiler and soem visualization system such as Matlab (recommended)
or Excel or gnuplot. You can purchase a compiler and or Matlab
at most computer stores, including the NYU computer store.

**Working with C/C++ and Matlab:** To use C/C++ for computing and Matlab for
visualization, you need to get results from the C/C++ into the Matlab environment.
One simple way to do this is to make your C/C++ program create a file that Matlab
can read. The files lis.C and lp.m give
one way to do this. In my UNIX environment, I type the command
"CC lis.C -o xlis" to compile the C++ program. Then I type "xlis" to
execute the compiled executable. First it asks the user to type a number,
then it creates a data file called "lis.m", which is really a few Matlab commands.
Look at the file to see what this means. In Matlab, I just type "lp" and all the
commands in that file are executed. The result should be a plot of a Lisajous figure.

**Learning C:** If you are not comfortable with C or C++, you need to get
comfortable right away. I recommend *The C Programming Language* by Brian
Kernighan and Dennis Ritchie. The first seven chapters suffice for most of what
we do in this course. To continue with C++, try *C++ Primer* by Stanley
Lippman. There are good Schaums Outline books on C and C++. Don't panic, the
first few assignments require very easy programs and the course materials
contain several program templates to work from.

**Learning Matlab:** The Matlab environment includes a primer for beginners.
Once you understand the basics of Matlab commands, you should start experimenting
with m-files such as "lis.m" and "lp.m". This avoids tedious typing and editing
of commands.