Modelling and control by Anthony Rossiter

MATLAB BASICS

 

This is a brief section on how to use MATLAB. It introduces the basic interface, variable types, efficient computation and solution display through m-files, potential uses. The focus is on a beginner who needs to be able to use the software to support simple undergraduate engineering problem solving, rather than on an advanced user. The first resource in Basics 2 gives a rapid introduction to the potential and is less a learning tool than for motivation. After this each resource is focussed on just one aspect at a time.

It is implicit in several of these chapters that students have core competence in any related mathematical or engineering topics.

This chapter contains the topics listed below. Under each topic there are hardcopy (pdf) notes, m-files and a video talk through with key illustrations done real time on MATLAB.

  1. Matlab Basics 2 - introduction to simple calculations and use.
  2. Matlab Basics 3 - matrices, vectors and arrays.
  3. Matlab Basics 4 - script files.
  4. Matlab Basics 5 - variable types.
  5. Matlab Basics 6 - plotting.
  6. Matlab Basics 7 - symbolic variables.
  7. Matlab Basics extra - interface and window sizing.
  8. Matlab Basics 8 - conditionals.
  9. Matlab Basics 9 - loops.
  10. Matlab Basics 10 - function files.

Matlab Basics 2 - introduction to simple calculations and use

Demonstrates the potential of MATLAB and hopefully enthuses viewers to learn the details given in later resources. Shows how to do simple mathematical computations in MATLAB and that these are far easier than on a conventional hand calculator, especially where expressions are long or complicated. Demonstrates how expressions can be saved or recalled and editted to make error correction and repeated computation efficient. Demonstrates with live MATLAB usage. Some aspects such as symbolic variables and script files are introduced very concisely to demonstrate the power and potential of MATLAB but viewers should use the later resources for a slower and more careful explanation of these aspects.

Return to top of this page

Matlab Basics 3 - matrices, vectors and arrays

Introduces the main variable type in MATLAB which is the matrix. Shows how numerical values are stored, accessed (or indexed), editted and created. Demonstrates with live MATLAB usage. To keep the lengths reasonable, comprises two separate videos covering vectors and then matrices; ideally these are viewed in order.

Return to top of this page

Matlab Basics 4 - script files

Many engineering algorithms require a number of steps, done in a specific sequence. This resource demonstrates how a sequence commands can be stored in a m-file and then executed with a single button press, thus being very efficient. Also demonstrates with live MATLAB usage how errors can be captured and corrected very efficiently.

Return to top of this page

Matlab Basics 5 - variable types

Different types of problems require different types of variable (real number, complex number, integer, transfer function, matrix, string, etc.). This resource introduces a number of different variable types available on MATLAB and briefly demonstrates their use with some real time illustrations. As this resource covers a broad range of variables, the intention is not to give a comprehensive training in the different variable types, but rather to raise user awareness of the possibilities so they know where to look should the need arise.

Return to top of this page

Matlab Basics 6 - plotting

Display of information is a core communication tool for engineers. This resource introduces the plot command in MATLAB and shows how easily plots can be created, modified, saved and exported for use in other software. Gives a number of live demonstrations and some supporting code for students to access and use as a template.

(i) Simple lines plots are around 2-4 min; (ii) Colours and line types are 4-6min; (iii) Labels, titles and legends 6-9min; (iv) Overlaying numerous plots 9-14min; (v) property editor 14-15min; (vi) subplots 15-17min; (vii) exporting to word processors 17min and (viii) live demonstrations 18-22min.

Return to top of this page

Matlab Basics 7 - symbolic variables

Many engineering problems require algebraic manipulation, differentiation, roots solving and so on, all of which are tedious on pen and paper. This resource shows how MATLAB supports basic algebra and also, allows the algebra to be converted to numerical values where required. Differentiation and integration is around 2-5 min, Tangents around 6min, Taylor series around 8min, live demonstrations 11-18 min (with a focus on subs.m around 14.30 and 17.20).

Return to top of this page

Matlab Basics extra - interface and window sizing

Demonstrates the basic MATLAB interface and the different windows which open. Discusses different screen layouts and how one can exploit these to ensure the layout is the most efficient one for the given task. This can be skipped by users who feel the content is largely intuitive or obvious

Return to top of this page

BELOW HERE IS IN PROGRESS

Matlab Basics 8 - conditionals

A typical engineering algorithm or procedure will involve some decision making process, for example if it is hot, turning the central heating off. This resource shows how MATLAB enables decision making to be embedded efficiently and intuitively in any sequences of commands.

Matlab Basics 9 - loops.

There are numerous occasions where the same sequence of commands needs to be executed on several different values (such as when generating a plot or table). MATLAB provides a loop structure for supporting this. This resources demonstates the loop structure and provides several m-files for students to use as templates to practice with.

Matlab Basics 10 - function files

A core requirement in the long term is to save validated code for reuse later. In order to ensure this code cannot interfere with other code and computations, the recommended format is a function file which takes given inputs, executes a specifed sequence of commands (algorithm) on these, and produces the required output. This resource introduces the function file syntax and provides several illustrations and exemplars.