MATH 349
MATLAB basics for LA

MATLAB is a very powerful and interactive software package for numerical computations. It is based upon matrices and m-files.

First, log on to your generic account {student} & {m4th4UD} . If you are unable to do that, please get a hold of me.

Open MATLAB and follow the bellow instructions. The text after the prompt (>>) represents a MATLAB command, and it should be typed in the Command Window. First, go to the home directory by typing (in the Command Window)

>> cd ~/

Then type

>> mkdir mywork (or whatever you wish to name this directory)

and

>> cd mywork

MATLAB can be used as a CALCULATOR. Try:

>>2^10

>> ans/2^8

MATLAB allows you to assign numerical values to a variable. Type

>> a=2, b=1

>> c=a +b

>> c=a + 2*b

>> c=a + 2*b;

>> c

If one ends a command by semi-column, MATLAB does its work ``silently'', but everything is still there.

MATLAB outputs numbers in various formats. Type,

>> c = sqrt(2)

>>format long

>> c

>> c =100* c

>>format

>>c

>>help format

Learn how to use the Command History (UP and DOWN arrow keys). Repeatedly pressing the ``UP Arrow'' key will review the previous commands. To re-execute a command, press the ``return'' key. Once a command is recalled it might be changed by using the ``left arrow'' and the ``right arrow'' keys.

Learn how to use MATLAB's extensive help.

  • The command >>help will return a list of topics. You can then type >>help topic on one of those topics or double click any of the listed topics. Type >>help matfun , and then >>help rref
  • A more efficient way to use the MATLAB help is to click on Help ( left-upper corner of the MATLAB window) and then, choose Product Help. You will get a new ``Help'' window with the main menu Contents: Index: Search: Demos and a small window (left top corner) for key word search

    The Reduced Row Echelon Form (RREF) of a matrix and rank

    To enter the matrix A with the rows [0 1 1 1], [1 -1 0 1] and [2 -1 1 1], in the MATLAB command window type

    >> A=[0 1 1 1; 1 -1 0 1; 2 -1 1 1] and then hit return

    Next, type

    >> rref(A)

    >> rank(A)

    After each command hit return. More to come...