Download presentation

Presentation is loading. Please wait.

Published byJocelyn Collins Modified over 4 years ago

1
MATLAB Lecture One Monday 4 July 2005

2
Matlab Melvyn Sim Department of Decision Sciences NUS Business School Email: dscsimm@nus.edu.sg

3
References l “Getting Started with Matlab,” by Rudra Pratap l “Matlab manual” by the MathWorks Inc.

4
Chapter 1

5
What is MATLAB l An interactive numerical computing environment l Matrix computations l Graphics l Programming (M-files) l Toolboxes (signal processing, statistics, optimization, symbolic math)

6
Advantage of MATLAB l Easy, interactive environment l Fast numerical algorithms l Inexpensive software l Fun and easy environment for learning Linear Algebra!!

7
Think Linear Algebra!! l More important and calculus!! l Background Knowledge Given two matrices, A and B, is AB = BA? A and B are symmetric Matrices, is AB symmetric? What is positive definite matrix? What is Eigenvalue decomposition?

8
Windows Environment MATLAB is essentially operating system independent

9
Input/Output l MATLAB handles double, char and logical data types l Array need not dimensioned l Variables are case sensitive l Output format can be controlled l Command history remembered

10
Files MATLAB Handle l M-files (*.m) are script and function files l Mat-files (*.mat) are created by MATLAB with save, and read with load l Mex-files (*.mex) MATLAB callable codes compiled from other languages

11
General Commands l On-line helps (help, helpwin, helpdesk, lookfor, demo) l Workspace (who, whos, what, clear, clc, clf) l Directory (pwd, cd, dir, ls, path) l General (computer, clock, date, more, ver) l Termination (^c, quit, exit)

12
Chapter 2

13
Tutorial Lessons

14
Lesson 1 l Assign values to variables l Basic arithmetic (+,-, *, /, ^) l Suppress screen output by ; l Float-point number appearance l Function sin, cos, log l Quit

15
Lesson 2 l Create row and column vectors l Linearly spaced vectors l Arithmetic on vectors l Array operations with.*,./,.^ l Math functions on vectors

16
Lesson 3: Creating and Printing Plot l Create points l 2D plots l Printing

17
Lesson 4: Script file l Create, write, save a script file l How to execute the script file l path, and addpath command l pwd and cd command

18
Lesson 5: Creating a function l Function file l Executing a function

19
Exercises l Lesson 3, exercise 3. An exponentially decaying sine plot: Plot y = exp(-0.4x) sin x, 0<x<4

20
Exercises l Lesson 5, exercise 2. Convert temperature: write a function that outputs a conversion table from Celsius and Fahrenheit temperatures. The two temperatures are related as F = (9/5) C + 32

21
Exercises l Best way to skin a cat!! l Given a vector x Find the sum Find the sum of squares

22
Exercise l Monte Carlo Sampling Generate N samples of the sum of M independent uniformly distributed random variables.

23
Histogram Plot

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google