Introduction to Matlab - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Introduction to Matlab

Description:

To give insight into a state of the art tool in technical computation and visualization ... load mandrill image(X); colormap(map) axis image off ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 30
Provided by: Fred191
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Matlab


1
Introduction to Matlab
  • 2E1215, Lecture 1

2
Overview
  • The Course 2E1215
  • Course contents and literature
  • Course Guide
  • Matlab Demo
  • Background to Matlab
  • Interactive Calculations
  • Vectors and Matrices
  • Graphical Illustrations

3
Course Objectives
  • Student Handbook
  • 1 credit self study course
  • Eligible for E and D
  • Objectives
  • To gain basic knowledge of the Matlab programming
    language
  • To prepare for other courses where Matlab is used
  • To give insight into a state of the art tool in
    technical computation and visualization

4
Matlab at KTH
  • 2D1240 Numeriska metoder
  • 5B1209 Signaler och system I
  • 2E1313 Signaler och system II
  • 2E1315 Signaler och system II, D
  • 2E1280 Modellering av industriella processer
  • 12E1200 Reglerteknik ak, F,M,T
  • 2E1211 Reglerteknik ak, E
  • 21252 E Reglerteknik fk
  • 2E1262 Olinjär reglering
  • 2E1291 Kemiteknisk processreglering
  • 2E1241 Projektkurs i reglerteknik
  • 2E1421 Signalteori
  • 2E1340 Digital signalbehandling
  • 2E1350 Adaptiv signalbehanling
  • 2E1366 Projektkurs i signalbehandling och digital
    kommunikation
  • 2E1431 Kommunikationsteori
  • 2E1435 Kommeunikationsteori fk
  • etc...

5
Prerequisites
  • Basic knowledge from calculus and linear algebra
  • Basic programming experience (helpful, not
    necessary)
  • Internet and computer experience
  • Curiosity!

6
Course Literature
  • An Introductory Matlab Course - with Engineering
    Applications
  • by Niclas Bergman and Fredrik Gustafsson.
  • The course includes Part 1.
  • Available at STEX (Osquldas v 10)
  • Teaches practical Matlab usage (not a full
    manual)
  • Basic description of theoretical concepts
  • Based on examples with guided tours of the system
  • Exercises with solutions
  • Suggested exercises 1-5, 8-17, 21, 23-32, 34, 37,
    40-41, 44, 47-48
  • Applications from engineering courses

7
Course Guide
control.s3.kth.se
  • Registration
  • Examination
  • Schedule
  • Information

8
Course Guide - Registration
  • control.s3.kth.se

Internet
InternetServer
9
Course Guide - Registration
  • Registration is mandatory
  • At the course webpage
  • This registration sent to DEF

10
Course Guide - Studies
  • Self studies, guided tours
  • Solve exercises in four computer sessions
  • Questions via E-mail
  • Examination by mail

?
11
Self studies - availability
  • The KTH CD-rom
  • Matlab is installed in most computer labs
  • On Linux machines at Elektro type

module add matlab matlab
12
Computer Exercises
  • D-students need account at Elektro
  • Course registration necessary.
  • Deadline Thursday 14/3
  • If you havent, choose user name at KTH
  • https//www.kth.se/student/login
  • Visit Elhand, Osquldas v 10, floor 2
  • 18/3 --- bring identity card

13
Course Guide - Marks within 24h

020216 2156
Internet
LADOK Report
020301
14
Matlab Background
  • MATLAB MATrix LABoratory
  • Originally a user interface for standard
    routines in numerical linear algebra
    (Lapak/Linpak) designed by Cleve Moler
  • Commercialized 1984 by Mathworks (3 pers)

15
Matlab Background
  • Swedish agent COMSOLCOMputer SOLutions Europe.
  • An alternative to MATLAB is MATRIX-X
  • Mathematica and Maple are complements
  • Octave is a free (GNU) alternative

16
Construction
  • The core functionality in MATLAB contains
    compiled C-routines
  • Most of the functionality is given as m-files,
    categorized in toolboxes
  • Dynamical simulation is performed in Simulink

Contr. Syst.
Sig. Proc
Simulink
m-files
C-kernel
17
Construction
  • Standard MATLAB contains thousands of m-files,
    source code that can be copied and altered
  • MATLAB is available for PC (Windows/Linux), Mac
    and Unix (Sun/HP/VMS/SGI/Alpha/...)
  • MATLABs m-files are platform independent
  • The latest version is called MATLAB 6.2, Release
    13 (2002).
  • Before that, we had Release 12.1, Matlab 6.1
    (2001), Release 12, Matlab 6.0 (2000) and
    Release 11, Matlab 5.3 (1999)

18
Interactive Calculations
  • Matlab is interactive and you do not have to
    declare variables
  • gtgt 234/2
  • gtgt a5e-3 b1 ab
  • Most elementary functions and constants are
    already defined
  • gtgt cos(pi)
  • gtgt abs(1i)
  • gtgt sin(pi)
  • Last call gives answer 1.2246e-016 !?

19
Floating point numbers in Matlab
  • IEEE Standard for double precision
  • x (1f )2e
  • f d1/2 d52/252, dk 0,1
  • -1022 lt e lt 1023
  • Round-off eps 2-52
  • Underflow realmin 2-1022
  • Overflow realmax (2-eps) 21023

20
Interactive Calculations
  • Matlab uses double precision which gives
    approximately 16 significant figures
  • gtgt format long
  • gtgt format compact
  • Variables can be stored on file
  • gtgt save dump
  • gtgt clear
  • gtgt load dump

21
Interactive Calculations
  • All variables are shown with
  • gtgt who
  • gtgt whos
  • Rapid help with syntax and function definition
  • gtgt help function
  • An advanced hyperlinked help system is launched
    by
  • gtgt helpdesk
  • All manuals are provided in PDF-format

22
Vectors and Matrices
  • Vectors (arrays) are defined as
  • gtgt v 1 2,4,-5
  • All common operators are overloaded
  • gtgt v 2
  • Visualization of vector data is available
  • gtgt plot(v)
  • gtgt plot(v,)
  • gtgt bar(v)
  • gtgt pie(abs(v))

23
Vectors and Matrices
  • Matrices (2D-array) are defined similarly
  • gtgt A 1 2 34,-5,65 -6,7
  • Common operators are available
  • gtgt B A
  • gtgt AB
  • gtgt AB
  • MATLAB is case-sensitive A and a are two
    different variables

24
Vectors and Matrices
  • Indexing using parentheses
  • gtgt A(2,3)
  • Indexing of a complete row/column is performed by
    the colon-operator
  • gtgt A(12,)
  • For instance, 12 is the same as 1 2,
  • 238 is the same as 2 5 8
  • Arbitrary indexing is allowed using vectors
    between 1 and the matrix dimension
  • gtgt A(3 2,2 1)
  • gtgt A(3,2) A(3,1)A(2,2) A(2,1)

25
Vectors and Matrices
  • Elementary functions are also overloaded
  • gtgt sin(A)
  • gtgt help elmat help elfun
  • Specialized matrix functions and operators
  • gtgt sqrtm(A)
  • gtgt A.2
  • gtgt A2
  • gtgt A.B

26
Vectors and Matrices
  • Numerical linear algebra
  • gtgt inv(A)
  • gtgt B\A
  • gtgt det(A)
  • gtgt rank(A)
  • The number of input and output arguments can
    often be varied
  • gtgt V,Deig(A)

27
Graphical illustrations
  • Three-dimensional graphics
  • gtgt A zeros(32)
  • gtgt A(1416,1416) ones(3)
  • gtgt Fabs(fft2(A))
  • gtgt mesh(F)
  • gtgt rotate3d on
  • Many visualization attributes can be changed from
    the figure menu (from version 5.3 and higher).

28
Graphical illustrations
  • Bitmap images can also be visualized
  • gtgt surfl(F)
  • gtgt load mandrill
  • gtgt image(X) colormap(map)
  • gtgt axis image off
  • Example of lighting and camera settings
  • gtgt knot
  • gtgt cameramenu
  • gtgt material metal

29
Next Lecture
  • Programming in MATLAB
Write a Comment
User Comments (0)
About PowerShow.com