Modelling, dynamics and control by Anthony Rossiter

Section on MATLAB Basics

MATLAB tools are are valuable for modelling, simulating and analysing feedback loops and indeed many engineering systems.

This section is on the theme of MATLAB. Here we introduce the basic environment and coding functionality, without an emphasis towards any particular discipline.

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.

All resources include live demonstrations of MATLAB and the supporting code that is demonstrated.

Matlab Basics 2 - introduction to simple calculations. Demonstrates the potential of MATLAB. Shows how to do simple mathematical computations and how expressions can be saved, recalled and editted to make error correction and repeated computation efficient. Some aspects introduced very concisely here available in more detail in resources below.

i. Video and pdf file.

iii. Supporting m-files: matlab_basics2.m, matlab_basics2b.m

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. To keep the lengths reasonable, comprises two separate videos covering vectors and then matrices; ideally these are viewed in order.

i. Video vectors in MATLAB and Video on matrices in MATLAB.

ii. PDF on vectors and PDF on matrices.
iii. Supporting files: matlab_basics3.m, matlab_basics3b.m

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. Live MATLAB usage shows how errors can be captured and corrected very efficiently.

i. Video and PDF file.

ii. Supporting files: matlab_basics4a.m, matlab_basics4b.m, matlab_basics4c.m, matlab_basics4d.m, matlab_basics4e.m.

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 demonstrates their use; the intention is not to give a comprehensive training, but rather to raise user awareness of the possibilities.

i. Video and PDF file.

ii. Supporting files: matlab_basics5.m.

Matlab Basics 6 - plotting. Display of information is a core tool. This resource introduces the plot command: (i) Simple lines plots 2-4 min; (ii) Colours and line types 4-6min; (iii) Labels, titles and legends 6-9min; (iv) Overlaying 9-14min; (v) property editor 14-15min; (vi) subplots 15-17min; (vii) exporting figures 17min and (viii) live demonstrations 18-22min.

i. Video and PDF file.

ii. Supporting files: matlab_basics6a, matlab_basics6b.m.

Matlab Basics 7 - symbolic variables. Many 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 2-5 min, Tangents 6min, Taylor series 8min, live demonstrations 11-18 min.

i. Video and PDF file.

ii. Supporting files: matlab_basics7, matlab_basics7b.m.

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.

i. Video and PDF file

ii. Supporting files: matlab_basics1.m, matlab_basics1b.m.

Matlab Basics 8 - conditionals. A typical 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. Four videos look at four mains concepts: if - else - end statements, while - end statements, switch - case - end statements and logical variables.

i. If statements: video, PDF, matlab_basics8a.m, matlab_basics8b.m, matlab_basics8c.m, matlab_basics8d.m, matlab_basics8e.m.
ii While statements: video, PDF, matlab_basics8f.m, matlab_basics8g.m.
iii. Switch statements: video, PDF, matlab_basics8h.m).
iv. Logical variables: video, PDF, matlab_basics8j.m, matlab_basics8k.m.

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). This resources demonstrates the "for loop" structure and provides several m-files for students to use as templates to practice with.

i. Video and PDF.
ii. Supporting files: matlab_basics9a.m, matlab_basics9b.m, matlab_basics9c.m, matlab_basics9d.m, matlab_basics9e.m, matlab_basics9f.m.

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.

i. Video and Notes.

ii. Supporting files: matlab_basics10a.m, matlab_basics10b.m

Matlab basics 11 - producing figures for reports. Many students use MATLAB to produce figures for reports, presentations and posters, but do this poorly. This video gives some simple hints on how to ensure the image that appears in your report is easy to read, well produced and with appropriately sized fonts throughout.

i. Video and notes.

ii. Supporting files: matlab_basics11.m, matlab_basics11b.m.