# Matlab Manual

Introduction to Engineering Computation

Laboratory Manual

MATLAB programming

Department of Engineering Science

MATLAB Laboratory Manual Contents

Laboratory 1: An introduction to MATLAB ............................................................................................ 2 Laboratory 2: Debugging, Functions and Problem Solving ............................................................22 Laboratory 3: Logical Operators, Conditional Statements and Loops ........................................32 Laboratory 4: Graphics and Image Processing ...................................................................................46 Laboratory 5: Strings and Files ................................................................................................................52 Laboratory 6: Linear equations and differential equations ..........................................................57

Laboratory 1: An introduction to MATLAB

GETTING STARTED

Your Tutor will show you how to login to the Network. Most of the applications you will use reside on File Servers rather than on the local hard drive of your computer. You have also been allocated an ec (Electronic Campus) home directory (H drive), in which you can save your work. If your computer is switched off (you can tell this by the absence of a light on the front of the computer) you should press the Power on the computer’s front panel. Do not switch the monitor on or off at any time! If the light is already on, you can simply restart the login sequence by holding down the Ctrl and the Alt keys and pressing the Delete key.

GENERAL LAB DIRECTIONS

You should work your way through the tutorials reading everything. Interaction with the computer takes place throughout the lab. The sections are not stand-alone so you must work through them in order. There are a number of assignment tasks throughout the Lab that will be checked by your tutor when you have completed the whole lab. Any MATLAB commands for you to type are shown as they would appear in MATLAB. Other MATLAB terms in a body of text will be bolded to make it easy to see. Please feel free to help your fellow students understand the concepts and never hesitate to ask questions of the tutors. Some labs include optional exercises at the end. These exercises are aimed at students who are able to complete the other lab tasks quickly and who wish to learn/practice more MATLAB. Completion of optional tasks is not required to get signed off for the lab. The material presented in optional exercises will often increase your understanding of MATLAB so if you have a chance give these exercises a go. Be sure to look out for

TASK There is a lab task to complete. TIP There is a handy tip to help you with MATLAB. Star There is a description of good programming practice. If you follow these tried and true conventions you will be a programming star! Stop There is a “roadblock to understanding”. Make sure you ask a tutor for clarification if you don’t understand what MATLAB is doing.

2

INTRODUCTION TO MATLAB

MATLAB (MATrix LABoratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB is especially designed for matrix computations: solving systems of linear equations, performing matrix transformations, factoring matrices, and so forth. In addition, it has a variety of graphical capabilities, and can be extended through programs written in its own programming language. MATLAB is supported on Unix, Macintosh, and Windows environments. A student version of MATLAB for Macintosh or Windows may be purchased from the Science Student Resource Centre, which you can install on your own computer.

MATLAB Advantages

It simplifies the analysis of mathematical models It frees you from coding in lower-level languages (saves a lot of time - with some computational speed penalties) Provides an extensible programming/visualization...

Please join StudyMode to read the full document