Chapter six
MATLAB resources
Section onE: 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 section two 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.
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 edited to make error correction and repeated computation efficient. Some aspects introduced very concisely here available in more detail in resources below.
Supporting m-files:
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), edited and created. To keep the lengths reasonable, comprises two separate videos covering vectors and then matrices; ideally these are viewed in order.
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.
Supporting files:
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.
Supporting file: matlab_basics5.m
6. Plotting
Display of information is a core tool. This resource introduces the plot command:
Simple lines plots 2-4 min;
Colours and line types 4-6min;
Labels, titles and legends 6-9min;
Overlaying 9-14min;
property editor 14-15min;
subplots 15-17min;
exporting figures 17min; and
live demonstrations 18-22min.
Supporting files:
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.
Supporting files:
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.
Supporting files:
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.
If statements:
While statements:
Switch statements:
Logical variables:
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.
Supporting files:
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 specified sequence of commands (algorithm) on these, and produces the required output. This resource introduces the function file syntax.
Supporting files:
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.
Supporting files: