THE WONDERFUL WORLD OF MATLAB

MORE MATLAB LINKS

UNIVERSITY BASED MATLAB LINKS

Matlab manual page
Running Batch Jobs
Matlab Tutorials
Manual.pdf
Matlab M-Files Database - Home

Matlab advancedhelp.pdf
Matlab compiler help compiler.pdf
Fortran and matlab
mPlot.f90 page



Matlab Batch jobs

Examples of the MATLAB API
matlab--executable files
Running Batch Jobs
A Guide to Computi...ter Intensive Jobs
Running Long Calculations
Matlab in background

PLOTTING WITH MATLAB

Plotting with Matlab



Introduction to MATLAB
Matlab General Purpose Commands
Getting Started with Matlab (The MathWorks)
Getting Started With MATLAB (Indiana University)
Helpful Information For Using MATLAB
Matlab Tutorial Information (University of New Hampshire)
MATLAB Hypertext Reference
Special Characters
Answers to Common How-To Questions about Matlab
Matlab Quick Reference
Matlab--Eight Lessons
MATLAB Tutorial by by Kermit Sigmon

MATLAB Tutorial (University of Utah)

MATLAB Basics Tutorial (Carnegie Mellon)

Some Useful MATLAB Commands
3-day MATLAB Tutorial from MIT
Matlab Manual (Rice University)

Tutorial from MIT's Athena

MATLAB Quick Refernce Guide (University of Waterloo, Canada)

Plotting Options and Tips for Matlab
A Brief Explanation of MATLAB M-Files
The MathWorks, Inc

 

SYMBOLIC MATH





EXAMPLE MATLAB FILE

CALLING MATLAB TOOLS FROM a f90 code


Matlab Engine interface examples

Compiling and linking "Matlab Engine" programs


One can call a matlab tool from a C, C++, f77 and f90 code without having to bring up the matlab browser or environment. This simple example will try to demonstarte how to call the plot(x,y) function from a f90 subroutine ot program.

CHECKING WHERE MATLAB IS LOCATED

COMPILE

  FOR MATLAB 7 THE SETTINGS ARE AS FOLLOWS
In order to interface the f90 part of the code to the matlab animation engine an environment variable needs to be set prior to the link step and the execution step. The environment variable must not be exported on log in! For some reason the kde session manager does not like it. However the Gnome session is ok with exporting it on log in. What one can do is set it up as a function that exports the environment variable when the user wants to use it. When it is set as a function the user executes the function by typeing the function name in the shell.  In the .bashrc file insert the following lines:

Steps
What to do
Insert the following lines in the .bashrc file as shown. The .bashrc file is located in /home/username.
function expmatlib
{
           m7=/usr/local/matlab7/bin/glnx86;
           export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$m7
}
Save and exit the .bashrc file and then source the file
<bash> source .bashrc <enter>
Before Compiling and Linking do
<bash> expmatlib  < enter>
compile the files
<bash> ifc -c -w  [file1.f90] ....... [filen.f90]
link the files
<bash> ifc [file1.o] ...... [filen.o]-o step1 -L/usr/local/matlab7/bin/glnx86/ -leng


LINK STEP

  • <bash> ifc plot.o -o step1 -L/usr/local/matlab7/bin/glnx86/ -leng

SURFACE PLOT ROUTINE WITH MULTIPLE PLOTS



INVOKING THE MATLAB ENGINE FOR 1-D TIME DEPENDANT CFD SOLUTION
It should be understood that when you invole the matlab engine your code will slow down.  For speed up and quick results the matlab engine should not be invoked.

The main.f90 file invokes the matlab engine
main.f90

The explicit.f90 file calls the matlab engine and passes the arrays into it
explicit.f90

The post_dt file is for the tecplot animation
post_dt.f90



RUNNING MATLAB JOBS ON whopper.eng.iastate.edu  OR ON THE PLANETS

Compute intensive jobs should always be run in the batch mode. There is no point sitting around wating fro your solution or x-locking the machine when you can safely submit jobs on aeem3 and whopper without any worries. How would you like it if people starting x-locking 4 to 5 machines until there is no available machine for you to work on ? I am sure you will be enraged and tempted to re-boot some of the machines. And you would be justified in doing so !!
If you x-lock a machine or machines and find out the next day when you saunter into lab that you jobs were killed; then you are to blame for your own negligence when there are ample facilities available to meet your compute intensive needs. If you are in the business of running compute intensive codes then you need to take the time to learn how to run them efficiently!

For Windows users:

Your AFS account (vincent account)

The afs account is your default home directory from ait. Currently all linux machines available to you in the dept. will access your afs account as your deffault home direcetory. To log into the machines use your vincent or acropolis password.

Your Engineering account

The engineering account is located at

<prompt>cd /clue/joeusr

where joeusr is a general username: you would replace with your username

AGH^&!@^ .... i cannot access the file, but its there .... i can see it (model case 1 new.m)

So you have a matlab file called model case 1 new.m. The problem is that in the command line you are only able to type model because the file name has spaces. To remedy this problem type the 1st word model and then press the tab key twice, the shell will complete the name and you should be ok. In unix the file name is associated as

<prompt>ls model\ case1\ new.m

unix will put forward slashes for spaces. I would recommend using names with no spaces.

REMEMBER!

Unix is a language and so you have to be able to communicate with the kernel or else garbage in is garbage out! Try to avoid spaces in names of files and directories. Also its better and more efficient to use lower case letters. Select this link to get familiar with the command line environment. Go through the Linux excercises to help you navigate on the Linux machines.


INSTRUCTIONS

Description of the task and the proper commands:
This should help users on the windows systems who are not conversant with the unix language. It is understood that the user knows how to launch the xwin32 program from his/her windows box. The user can launch either the kde based version or the basic shell based version. For speed and efficiency it is recommended to launch the shell based version. When using large files and computational intensive jobs there is a good chance the remote connection will lag or sometimes hangup. For big jobs its recommended to ssh from a linux machine, submit the job and log out. You should also check the load on the current machine that you have logged into by using the  top command. Check the CPU% usage and then decide whether to submit the job or move to another machine.

step1

Log into one of the servers using the xwin 32 tool for windows users.

<prompt>ssh -l joeusr mercury.aere.iastate.edu

step1b

Check to see if there is enough space in /remote/aere directory. This directory gets filled up pretty often due to heavy load.

<prompt>df
                       storage.eng.iastate.edu:/export/scratch
                       88G   77G  6.6G  93% /remote/scratch


step2

open up a shell or from existing shell enter the proper directory. List the contents of the directory using the ls command and make sure the matlab code is in the dir.

<prompt>cd directory
<
prompt>ls


step4: Launching matlab and stay logged into the machine

launch matlab without gui, however you will remain logged in while the job runs

<prompt>matlab -nojvm

launch matlab with gui and remain logged on

<prompt>matlab

step5: Launching matlab, executing a code and log out ---> True Batch Process

If the user wishes to launch a matlab program and log out of the server than a batch process has to inititiated. The matlab program shoud be launched without the gui! The user should launch the matlab program without the gui as a background process using the & at th end of the command. The code is read in through the command as standard input using the < sign. Any output that would ordinarily go to the screen should be dumped into a file or into /dev/null where it disappears. If the output is to be saved then output the file into the scratch dir.

<prompt>nohup matlab -nojvm < code.m > /dev/null &

<prompt>nohup matlab -nojvm < code.m > /remote/aere/joeuser/output.dat &

To check whether the command has been successful logout of the machine and loh back in the same way. Then on a prompt test the status of the processes on the machine

<prompt> top

The top command will list all the processes. Look for your user name on the 2nd column and the coressponding matlab name on the last column (keep pressing enter). The 1st column contains the process id
To exit the top utility press
CTRL C

ATTENTION

If you wish to run more than one batch process simultaneously and the matlab .m file is saving the data to a file, then each case should save the data to a new file. In other words each case should be given a new output file name.

step6:Killing a backgroundJob or Process

Its important to know how and when to kill a job. If you decide that the job submitted is wrong then kill it and resend the corrected case. As a user you need to excercise this responsibility so that others are not inconvenienced. See link for details

<prompt>jobs
<prompt>kill %[number coressponding to the job]
or
<prompt>top
<prompt>kill process number


MATLAB PATH NOT DEFINED

If for some users the shell cannot recognize the matlab command use the following
/usr/local/matlab7/bin/matlab


Mounting files from Cdrom or Usb key

If you need to access the .m files from an usb key or cdrom then follow the instructions

Cdrom:

Insert the CD into the CD drive of a Linux workstation.

<prompt>mount /media/cdrecorder
<prompt>cp -rf /media/cdrecorder/filename newfilename

When finished with the CDrom unmount the drive

<prompt>umount /media/cdrecorder

Usb key

Insert the usb key and list the contents of the media dir. The name of the key should be noted (it won't be floppy or cdrecorder!)
<prompt> ls /media
<prompt>mount /media/usbkey_name
<prompt>
cp -rf /media/usbkey_name/filename newfilename

When finished with the key unmount the key

<prompt>mount /media/usbkey_name

GRAPHICAL DESKTOP

If you do not want to use the command line then you can either use the kdeskop or nautilus utility