A brief introduction to MATLAB for students of Science, Engineering and Mathematics Jorge Lemagne Bindura University.

Slides:



Advertisements
Similar presentations
StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Advertisements

Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to SPSS Short Courses Last created (Feb, 2008) Kentaka Aruga.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Basics of MATLAB By DR. Wafaa Shabana
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Scientific Computing Introduction to Matlab Programming.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2012.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Matlab for Engineers Matlab Environment Chapter 2.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Introduction to MATLAB
Computer Application in Engineering Design
Introduction to Matlab
Lecture: MATLAB Chapter 1 Introduction
Statistical Computing in MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
Lecture 1: Introduction
StatLab Matlab Workshop
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Communication and Coding Theory Lab(CS491)
Presentation transcript:

A brief introduction to MATLAB for students of Science, Engineering and Mathematics Jorge Lemagne Bindura University

Summary IntroductionGetting started with MATLABIllustration in Math courses 2

What is MATLAB? MATLAB is a high-level language and interactive environment for numerical computation, visualization, and programming (MathWorks, 2013). 3

Some applications of MATLAB Signal processing and communicationsImage and video processingControl systemsTest and measurementComputational financeComputational biology 4

Widely used More than a million engineers and scientists in industry and academy use MATLAB, a language of technical computing. 5

Also an aid for mathematics students Moreover, MATLAB is a teaching and learning aid for mathematics students. It has been integrated as a supplement to the traditional classroom teaching and learning. For example, at University of Ha'il, Saudi Arabia, a study was made on engineering mathematics students. 6

Benefits The use of the software has enhanced students' conceptual understanding despite their weak mathematical skills. It has been noticed that students' attitudes have been positive and their performance in the course has improved 7

For mathematics courses Students taking some mathematics courses are expected to acquire a basic working knowledge of MATLAB (University of Utah). MATLAB may be used to help complete some of the homework assignments. Also for the completion of designated computer assignments (University of Utah). 8

Some requirements Students need to have access to a computer with MATLAB installed (Massachusetts Institute of Technology, 2015). They should have a way to access their files whenever they start working. In particular, they need to have access to MATLAB outside of class hours. 9

A two hours introduction In the bibliography there exist several good tutorials on MATLAB. However, a student would need considerable time to assimilate any of them, and so would a lecturer for the explanation. The brief introduction that is presented in this contribution can be explained in two hours and has been exposed as a lecture by the author at Bindura University. 10

In a computer laboratory Preferably, this lecture should be given in a computer laboratory so that the students can verify in practice all explanations. After learning this brief introduction the students will be able to solve simple problems, or to study a tutorial or to pass a course on MATLAB more easily. 11

Summary (2)  Introduction  Getting started with MATLAB Illustration in Math courses 12

GETTING STARTED WITH MATLAB The name MATLAB stands for MATrix LABoratory. The basic data element in MATLAB is an array that does not require dimensioning. 13

Much faster This allows you to solve many technical computing problems, especially those with matrix and vector formulations, in a fraction of the time it would take to write a program in a scalar non-interactive language such as C or FORTRAN. 14

Starting MATLAB On Windows platforms, to start MATLAB, double click the MATLAB shortcut icon on your Windows desktop. After a short lapse, you will see something like this: 15

Command Window For the time being we only need this window, the Command Window. If there are others open, we can close them. 16

Vectors Let us start to use the Command Window, manipulating some vectors (i.e. arrays of one dimension). 17

You can work with entire arrays Where other programming languages work with numbers one at a time, MATLAB allows you to work with entire arrays quickly and easily. 18

To enter arrays We can enter arrays into MATLAB in several different ways. an explicit list of elements One of them is by entering an explicit list of elements. 19

Entering vectors: Example At the command line, after MATLAB prompt “>>”, type this statement: >> a = [ ]; >> This instruction or statement assigns the vector [ ] to the variable “a”. 20

An assignment operator >> a = [ ]; “=” does not have the same meaning as in Mathematics. an assignment operator In this case, it is not a relational operator but an assignment operator. 21

Workspace Workspace Once you have entered the array, it is automatically remembered in the MATLAB Workspace: You can refer to the array, simply by its name, in this case “a”. 22

The Colon Operator The colon “:” is one of the most important MATLAB operators. It occurs in several different forms: The expression 1:7 is a row vector containing the integers from 1 to

For non-unit spacing Specify an increment. >> 0:pi/4:pi ans = ans Note: When you do not specify an output variable, MATLAB uses the variable “ans”, short for answer, to store the results of your calculation. 24

The Colon Operator: Another example 25

Sin function between 0 and 2π and step 0.1 (1) 26

Hundreds of available functions MATLAB has hundreds of available functions. To display documentation of one, for example, sin, type >> doc sin 27

M files M files M files are text files containing MATLAB code. To create an M file we can use the MATLAB Editor or another text editor. 28

MATLAB Editor (1) 29

The same statements The M file will contain the same statements you would type at the MATLAB command line. Save the file under a name that ends in “.m”. 30

MATLAB Editor (Rev) 31

Plotting “sin” with specified step 32

Content of M file % This very simple program plots sin(x) for % different values between 0 and 2*pi. Answer = inputdlg(‘Step size=‘); Step = str2double(Answer); x = 0:Step:2*pi; y = sin(x); plot(x,y,'*') 33

Input dialog box 34

Content of M file (Rev) % This very simple program plots sin(x) for % different values between 0 and 2*pi. Answer = inputdlg(‘Step size=‘); Step = str2double(Answer); x = 0:Step:2*pi; y = sin(x); plot(x,y,'*') 35

Sin function between 0 and 2π and step 0.1 (Rev) 36

Script script The M file corresponding to the preceding program is called script. Scripts are the simplest kind of M files because they have no input or output arguments. 37

Matrices and Subscripts Let us create the matrix >> A = [ ]; >> Dürer's magic square This table is known as Dürer's magic square. 38

Dürer Albrecht Dürer (1471–1528) was a painter, printmaker and theorist of the German Renaissance. Dürer’s Self-Portrait at 28 (a), Melencolia I (b) and Detail of Melencolia I (c) 39

Dürer's magic square [ ] Sum is 34 Sum is 34 by: Rows Columns Diagonals Quadrants In the center four squares In the corner squares etc. 40

Sums by columns A = [ ] Let us verify a few of these features. The first instruction to try is >> sum(A) ans = by columns These are the sums by columns. 41

Sums by rows A = [ ] by rows To obtain the sums by rows, we consider first A’, the conjugate transpose of A. Then, we type: >> sum(A')' ans = 34 42

Sum on the main diagonal A = [ ] on the main diagonal The sum of the elements on the main diagonal is obtained with “sum” and “diag” functions: >> sum(diag(A)) ans = 34 43

Subscripts with colons Subscript expressions involving colons refer to portions of a matrix. For example, sum(A(:, 4)) computes the sum of the elements in the fourth column of A: >> sum(A(:, 4)) ans = 34 44

Another way for creating matrices On the example of order-4 magic square, we created a matrix by entering an explicit list of elements. A = [ ]; Another way is by “load” command. See paper. 45

Summary (3)  Introduction  Getting started with MATLAB  Illustration in Math courses 46

ILLUSTRATION IN MATH COURSES The author of this paper is introducing MATLAB in his courses. Here are two examples: 47

Multivariate Methods The following table shows the heights (in inches) and the weights (in pounds) for 10 employees of a firm (Taken from Makridakis & Wheelwright (1983)) Examine the extent of the relationship between the two measures. 48

To solve Height_Weight problem (1) Create Create an M file with the preceding table Save Save it as Height_Weight.m (for example). In the Command Window, type: >> load Height_Weight.m >> mean(Height_Weight) ans = >> % These are the corresponding means. 49

To solve Height_Weight problem (2) >> cov(Height_Weight) ans = >> % This is the covariance matrix. 50

To solve Height_Weight problem (3) >> corrcoef(Height_Weight) ans = >> % This is the correlation coefficient matrix. >> The sample is not large, but we might say there is quite a strong relationship between the two variables. “mean”, “cov” and “corrcoef” are only three of the many functions that can be used in MATLAB. 51

Optimization 52

Graphical solution of Optimization problem Therefore, the solution is z=8. 53

REFERENCES (1) Majid, M.A., Huneiti, Z.A., Al-Naafa, M.A. & Balachandran, W., (2012), A study of the effects of using MATLAB as a pedagogical tool for engineering mathematics students, Interactive Collaborative Learning (ICL) 15th International Conference on,

REFERENCES (2) Makridakis, S., & Wheelwright, S (1983), Forecasting methods and Applications, 2nd edition, New York Wiley Massachusetts Institute of Technology (2015), Syllabus, MIT OpenCourseWare, s997-introduction-to-matlab-programming- fall-2011/Syllabus/ s997-introduction-to-matlab-programming- fall-2011/Syllabus/ 55

REFERENCES (3) MathWorks, The, Inc., MATLAB R2013a University of Utah, The, Department of Mathematics, (n. d.), MATLAB Information,

REFERENCES (4) Wikimedia Foundation, Inc., (2015), Magic square, Wikipedia, Wikimedia Foundation, Inc. York University (n. d.), MATLAB LESSON 1,