Source of Stress

Only available on StudyMode
  • Topic: Matrix, Dot product, Matrix multiplication
  • Pages : 36 (6447 words )
  • Download(s) : 107
  • Published : March 25, 2013
Open Document
Text Preview
Introduction to MATLAB
Anthony J. O’Connor School of Science, Griffith University, Brisbane, Australia


What is MATLAB ?

MATLAB started as an interactive program for doing matrix calculations and has now grown to a high level mathematical language that can solve integrals and differential equations numerically and plot a wide variety of two and three dimensional graphs. In this subject you will mostly use it interactively and also create MATLAB scripts that carry out a sequence of commands. MATLAB also contains a programming language that is rather like Pascal. The first version of Matlab was produced in the mid 1970s as a teaching tool. The vastly expanded Matlab is now used for mathematical calculations and simulation in companies and government labs ranging from aerospace, car design, signal analysis through to instrument control & financial analysis. Other similar programs are Mathematica and Maple. Mathematica is somewhat better at symbolic calculations but is slower at large numerical calculations. Recent versions of Matlab also include much of the Maple symbolic calculation program.

In this lab you will cover the following basic things:

• • • • • • • •

using Matlab as a numerical calculator entering row vectors and column vectors entering matrices forming matrix and vector products doing matrix products, sums etc using Matlab to solve linear equations Matlab functions that operate on arrays Plotting basic graphs using Matlab.

Matlab introduction



How to get started

When the computer has started go through the following steps in the different menus • • Look for the Network Applications folder and double click on that Within this you will see a little icon for Matlab61 – double click on that

Within about 30 seconds Matlab will open (you may get a little message box about ICA applications – just click OK on this) You should now see a screen like the picture below

This is the Matlab screen – it broken into 3 parts On the right you have the Command Window – this is where you type commands and usually the answers (or error messages) appear here too On the top left you have the Workspace window – if you define new quantities (called variables) there names should be listed here. On the bottom left you have Command History window – this is where past commands are remembered. If you want to re-run a previous command or to edit it you can drag it from this window to the command window to re-run it.

Matlab introduction



The Matlab prompt is >> .

Look at the Command Window and you will see the cursor flickerring after the >> prompt. This means that Matlab is waiting for further instructions.


Seeing the Matlab demo.

Just type the command >> demo (and then press Enter or Return key)

and run the simple slideshow under the Matrix manipulation option. This briefly shows you some of the things that Matlab can do - don’t worry if you do not know what everything means here.

Matlab introduction



Simple arithmetic with Matlab

The basic arithmetic operators are +, -, * (for multiplication), / (for divide) & ^ for powers. Where necessary brackets should be used to make the order in which things are evaluated completely clear. Enter the following commands to learn the basic way that formulas can be evaluated in Matlab (press enter after you have typed in the command. Record the answer beside the command.


3 + 5 -7


The result of this calculation is stored in the temporary variable called ans. It is changed when you do another calculation. If you want to save the answer from a calculation you can give it a name e.g. >> t=3+5-7 ..........................................................................

This line creates a variable t to save the answer in. If you want to find out what t is use


tracking img