# TSRT04 Introduction in Matlab

MATLAB is a software for scientific computations that is used internationally by many engineers. The course intends to give a basic knowledge of MATLAB and practical experience of working with the software. Particular focus is put on the ability to perform basic computations and simulations, as well as visualising simulation results. The course can both be seen as a preparation to a large number of university courses where Matlab is used, and as a possibility to learn a powerful engineering software. Basic knowledge in MATLAB is very useful for engineering students, since it is expected in many courses.

This course contains:

- Introduction to MATLAB and interactive computations.
- MATLAB syntax and review of common built-in MATLAB functions.
- Programming in MATLAB using m-files: scripts and functions.
- Simple linear algebra and calculus in MATLAB.
- Visualization of data and computational results.
- Practicing on problem solving by dividing a project into smaller pieces that can easily be tested and validated.

## Introduction

The course consists of an introductory lecture, two 2-hour computer lessons, and five 2-hour lab exercises. The lessons are optional (but highly recommended), while **the lab exercises are mandatory until the plot assignment and mini-project have been finished**. The examination consists of an individual quiz and presentation of the plot assignment and mini-project. The quiz is solved at Lab 1 while the presentation of assignments can be made at Lab 3 and Lab 5.

Since the lessons and lab exercises take place in computer rooms, everyone who takes the course needs to be divided into groups. You should register to a group in our registration system immediately when the course starts:

**Registration to lessons and lab exercises can be done in Lisam after the course has started (2019-09-02).**

Note that you select a lesson group and a lab group and thereby register for two lessons and five labs, the dates in Lisam indicate the first lesson and first lab (the full schedule is in TimeEdit). You can choose different lesson and lab groups.

The rest of this page contains information regarding all parts of the course. Here are links each part:

- Lecture
- Lessons
- Lab exercises
- Quiz
- Homework
- Examination
- Collection of course material
- Additional information

### Lecture

The course begins with a lecture that is given by the course examiner, Håkan Johansson. It is strongly recommended to attend this lecture (at least the first hour), so that you won't miss any information around the course structure, goals, and examination process. You are also expected to read this entire webpage, so that you are aware of all materal, information, and links.

At this lecture we will also go through the MATLAB basics and how to make simple computations and illustrations in MATLAB. We go through basic control structures, such as if statements, for- and while loops, and how these are written in MATLAB.

- The presentation slides from the lecture can be downloaded in Swedish or in English.

### Lessons

The two lessons are scheduled for the first and second week of the course. The lessons take place in computer rooms and you are expected to work in pairs. The lessons are based on self-studies where you go through the lesson material (see below). Course assistants are available to answer questions and give general advice. Please take the opportunity to ask whenever something is unclear! **The goal with the lessons is to learn the MATLAB basics and these parts are examined by an individual quiz at the first lab session.**

During HT1 2019, the lessons are led by:

Maria Posluk, marpo758@student.liu.se

Martin Allander, maral665@student.liu.se

**Lesson 1** gives an introduction to MATLAB. How to start the software and where to find more information? We use MATLAB as a pocket calculator, define and make computations with matrices, and draw graphs. How to use the built-in help functionality in MATLAB, and how to save your work and write documentation? We also write a few simple scripts and functions.

**Lesson 2** contains the basics of programming. We have a close look at one of the most powerful aspects of MATLAB: to write your own functions and programs that can be used just as the built-in functions.

- Description of Lesson 1: in Swedish or in English.
- Description of Lesson 2: in Swedish or in English.

### Lab exercises

A series of mandatory lab exercises, "computer laborations", are given from course week three to seven, one per week. You need to register for a lab series (see the link above) and attendance will be checked. The lab exercises are led by the same people as the lessons. The examination is taken care of by PhD students and postdocs from the Division of Communication Systems.

The lab exercises consist of two parts: one assignment where MATLAB's plot functions are used to visualize data, and a somewhat larger programming assignment that we call the "mini-project". These assignments are solved in groups of two students (three is too many, one is acceptable in special cases).

**Lab 1:** You should have learnt the basics of MATLAB in preparation for the first lab exerice, so that you are ready to begin with the problem solving. To validate your knowledge you need to solve an individual quiz at the beginning of the lab exercise (see details below). During the rest of Lab 1, you and your colleague will begin with the plot assignment and the mini-project, with help from the course assistants.

**Lab 2-5:** You and your colleague will continue during the remaining four labs (and outside the classroom) to finish the assignments. Please note that these assignments require a lot of homework if you are unfamiliar with programming, so you should spend time on the course each week and take the opportunity to ask the course assistents! The labs (one per week) are mandatory until the mini-project and plot assignment have been solved and presented. If you are experienced in programming and finish early, then you will find some additional tasks in the project description. These require a bit more of programming skills.

Choose one plot assignments and one mini-project from the following alternatives:

- Plot assignment 1 (Data traffic): in Swedish or in English. You also need to download the data set.
- Plot assignment 2 (Ecology): in Swedish or in English. You also need to download the data set.
- Mini-project 1 (Allocation of seats in elections): in Swedish or in English. You also need to download the results from the latest election to the European parliament. (Hint: You will learn to use iterative algorithms)
- Mini-project 2 (Cell phone coverage): in Swedish or in English. (Hint: You will learn to make 3D-plots)
- Mini-project 3 (Five-of-kind in Yatzy): in Swedish or in English. (Hint: You will learn Monte-Carlo simulation)

**The solutions should be demonstrated and the code should be presented at Lab 3 or Lab 5. You are most welcome to present the plot assignment at one occasion and the mini-project at another occasion. When you have passed all the assignments, then the lab exercises will no longer be mandatory for you.**

Note that your code that solves the mini-project must be sent to Urkund (an anti-plagiarism system) when you have passed the project. You find the exact instructions on page 2 of the project description.

**Some common questions:**

1. What happens if I finish the project before an occasion that offers examination? Answer: You need to show your code and your results to the lab assistant, who will give you feedback. When the assistant is satisfied and have marked this on the attendance list, then you leave and come back at the next occasion that offers examination.

2. What happens if I fail the quiz? Answer: We will offer a second chance to solve the quiz at a later occasion.

3. What happens if I cannot attend a lab session? Answer: The lab sessions are mandatory and you therefore need to send a mail to the course director and give a short explanation to your absence. You can attend a lab session of another group if there are empty seats. Otherwise you need to work on the project by yourself and bring all questions that arise to the next lab session.

4. Should I submit also the plot assignment code to Urkund? Answer: No, you only need to submit the code necessary to solve the mini-project.

### Quiz

At the first lab exercise, the material from the lessons is exmined by an individual quiz. The quiz will test basic knowledge of MATLAB's built-in functions (e.g., to create matrices, indexing, and drawing plots) and syntax (e.g., to write correct control structures and to spot errors in example code).

Note that the quiz is individual and shall be solved without any reference material (no material from lessons, no access to MATLAB). The quiz will be in English. At least half of the questions must be answered correctly to pass.

- Detailed description in English of what you need to know and example of how the quiz may look like.

If you cannot attend the quiz or did not pass, we offer an extra chance at an occasion that is marked as "Dugga" in the course schedule.

### Homework

This course consists of 16 hours in lecture/class rooms and you are thus expected to spend up to 37 hours on self-studies (5-6 hour per week). If you have a computer we recommend you to install MATLAB on it, so that you can work at home. All students at Linköping University have the possibility to borrow a MATLAB license, due to a special license agreement with Mathworks. The software is available for download at the the Student portal. We are not answering questions on the license and downloading part, but kindly ask you to contact helpdesk@student.liu.se.

In the description to Lesson 1 there is a number of homework problems, which we recommend you solve during the first two course weeks, as an extra preparation for the quiz. After that, you should work on the plot assignment and the mini-project some hours each week. If get stuck while working at home, you are welcome to contact the course assistant of your group. All questions regarding course material and practicalities can be sent by e-mail.

## Examination

**Read this carefully!** The course examination consists of the following parts:

- An individual quiz at the first lab exercise.
- Presentation of the code that solves one (1) plot assignment.
- Solution to one (1) mini-project. The teacher will run the code for a few test cases, ask some questions, and have a look at the code. The code should solve all the problems mentioned in the project description and must be easy to read and use. This means, in particular, that it follows the examination and coding style guide below.

## Collection of course material

The course material consists of:

- Lecture notes: in Swedish or in English.
- Description of Lesson 1: in Swedish or in English.
- Description of Lesson 2: in Swedish or in English.

**Plot assignment**: Choose **one** of the following plot assignments to solve and present during the lab exercises:

- Plot assignment 1 (Data traffic): in Swedish or in English. You also need to download the data set.
- Plot assignment 2 (Ecology): in Swedish or in English. You also need to download the data set.

**Mini-project**: Choose **one** of the following mini-projects to solve and present during the lab exercises:

- Mini-project 1 (Allocation of seats in elections): in Swedish or in English. You also need to download the results from the latest election to the European parliament. (Hint: You will learn to use iterative algorithms)
- Mini-project 2 (Cell phone coverage): in Swedish or in English. (Hint: You will learn to make 3D-plots)
- Mini-project 3 (Five-of-kind in Yatzy): in Swedish or in English. (Hint: You will learn Monte-Carlo simulation)

**Examination and coding style guide **: Please read this document to understand what we expect from you when you present your project:

- Guide in Swedish or in English.

**Certificate**

- You need this certificate as a reference of having completed different parts of the examination. Please keep it until you have received your course credits!

## Additional information

### External material

- The detailed MATLAB documentation is enough as reference material. You will find the documentation in MATLAB and on Mathwork's homepage.
- We recommend the following short video tutorial: //youtu.be/tqjZ80PwqBU?list=PL7CAABC40B2825C8B (8 short videos, with a total of 45 min).
- A longer video tutorial, including quizes is available from Mathworks: MATLAB Fundamentals Academic Tutorial
- A short MATLAB tutorial by Kelly Black, Clarkson University: MATLAB Tutorial.
- A concise MATLAB manual has been written by Mikael Olofsson at ISY, for our continuation courses: Short MATLAB Manual.
- If you like to read a book then you might find the following summary suitable. There are many other MATLAB books (both in Swedish and English), but you will not need one to pass this course.

### Important links

### Computer account and Linux

You will need a computer account at ISY to follow the lessons and lab exercises. You should normally get it automatically when you applied for the course. If you experience any problems related to computer account, you should contact the computer support: //www.isy.liu.se/en/tus/.

In computer rooms with Linux, you launch MATLAB by writing:

*module add prog/matlab/9.0*

*matlab*

If you want to use Windows-like shortcuts on a Linux computer, you can choose this under Preferences/Keyboard/Shortcuts in MATLAB.

Page responsible:
Håkan Johansson

Last updated: 2019 08 22 13:59