------------------------------------------------------------------------- PHYS210: MATLAB LAB 1 ------------------------------------------------------------------------- o NOTE: Solution to last lab's Maple programming exercises available at ~phys210/maplesolns/myprocs4soln ------------------------------------------------------------------------- o Login and open a terminal window and have a browser pointed to these notes as usual o Create the subdirectory 'matlab' in your home directory; we will be using it extensively to copy/create Matlab code, though not today % cd % mkdir matlab o In the lab we will generally use Matlab via the GUI, but there is also a command-line mode that will be useful at times, in particular if you want to use Malab remotely (e.g. at home via a ssh client) o We will thus consider 3 ways to start Matlab ------------------------------------------------------------------------ 1) GUI VERSION FROM DASH/LAUNCHER ------------------------------------------------------------------------ o Locate MATLAB from the Dash, drag and drop to Launcher, start it o Give focus to "Command Window" o '>>' is the Matlab prompt, do not type when following along with notes o Try >> 3 + 5 or some other simple arithmetic computation o Exit Matlab by typing 'quit' or 'exit' at the command prompt >> quit or >> exit or by killing the window (clicking on the x in the upper left corner) ------------------------------------------------------------------------ 2) GUI VERSION FROM BASH COMMAND LINE ------------------------------------------------------------------------ o In a terminal window type % matlab o Again, try >> 3 + 5 or some other simple arithmetic computation o Exit Matlab per above ------------------------------------------------------------------------ 3) COMMAND LINE VERSION ------------------------------------------------------------------------ o In a terminal window type the following % matlab -nodesktop -nosplash The options supplied to the matlab command mean the following o -nodesktop --- start command line version o -nosplash --- skip the display of the Matlab info/copyright window that normally appears during startup Will take a few seconds, and perhaps more than a few, to start, can safely ignore error messages that appear o NOTE: If command line matlab seems like it's taking an inordinately long time to start, i.e. it appears to "stall" after ... To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. ... is displayed, try typing Ctrl-C (interrupt), and the prompt should appear o Once more, after the prompt has appeared, try something such as >> 3 + 5 o Type 'exit' or 'quit' to exit command line Matlab o RECOMMENDATION: Add the following alias to your ~/.aliases file alias mat='matlab -nodesktop -nosplash' so that you can simply type 'mat' at the bash command line to start command line Matlab ------------------------------------------------------------------------ o Restart GUI version of Matlab o Matlab commands that we are typing are available via Syllabus, Chap 1 Calcs, Chap 2 Calcs (also course notes page), or directly via http://laplace.physics.ubc.ca/210/Doc/matlab/matlab1.html http://laplace.physics.ubc.ca/210/Doc/matlab/matlab2.html o Type along ... ------------------------------------------------------------------------ OCTAVE o At bash command line type % octave o Try executing a few of the Matlab commands we have tried o Type 'quit' or 'exit' to leave o NOTE: Octave is available for Linux and Mac OS, can use it for your homework and/or projects, but PLEASE check with me first if you intend to do so! ------------------------------------------------------------------------ ------------------------------------------------------------------------ EXERCISE o Add alias 'mat' as defined above to your ~/.aliases file o Test by starting new terminal session and typing ... % mat ... to ensure that command line Matlab *does* start