1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.

Slides:



Advertisements
Similar presentations
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 3.
Advertisements

Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
Solution of Simultaneous Linear Algebraic Equations: Lecture (I)
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Matrix Mathematics in MATLAB and Excel
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
Modified Gary Larson Far Side cartoon
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
4.2 Operations with Matrices Scalar multiplication.
259 Lecture 14 Elementary Matrix Theory. 2 Matrix Definition  A matrix is a rectangular array of elements (usually numbers) written in rows and columns.
Chapter 10 Review: Matrix Algebra
ECON 1150 Matrix Operations Special Matrices
Matlab tutorial course Lesson 2: Arrays and data types
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Review of Matrices Or A Fast Introduction.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
Learner’s Guide to MATLAB® Chapter 2 : Working with Arrays.
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Lecture 28: Mathematical Insight and Engineering.
Unit 3: Matrices.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Recap Script M-file Editor/Debugger Window Cell Mode Chapter 3 “Built in MATLAB Function” Using Built-in Functions Using the HELP Feature Window HELP.
Examples of linear transformation matrices Some special cases of linear transformations of two-dimensional space R 2 are illuminating:dimensional Dimoffree.svgDimoffree.svg‎
Working with Arrays in MATLAB
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 7.3 Matrices.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
8.2 Operations With Matrices
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
September 15, 2005 Lecture 5 - By Paul Lin 1 CPET 190 Lecture 5 Problem Solving with MATLAB
Sec 4.1 Matrices.
MT411 Robotic Engineering Asian Institution of Technology (AIT) Chapter 1 Introduction to Matrix Narong Aphiratsakun, D.Eng.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
ENG College of Engineering Engineering Education Innovation Center 1 Array Operations in MATLAB 1.Types of Matrix arithmetic 2.Dot operators Mathematical.
Unit 3: Matrices. Matrix: A rectangular arrangement of data into rows and columns, identified by capital letters. Matrix Dimensions: Number of rows, m,
Do Now: Perform the indicated operation. 1.). Algebra II Elements 11.1: Matrix Operations HW: HW: p.590 (16-36 even, 37, 44, 46)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 8 Linear Algebraic Equations and Matrices.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
MTH108 Business Math I Lecture 20.
Linear Algebraic Equations and Matrices
Chapter 7 Matrix Mathematics
Linear Algebraic Equations and Matrices
Matrix Operations SpringSemester 2017.
7.3 Matrices.
Lecture 11 Matrices and Linear Algebra with MATLAB
Unit 3: Matrices
ARRAY DIVISION Identity matrix Islamic University of Gaza
1.8 Matrices.
Matrix Operations Ms. Olifer.
Matrix Operations SpringSemester 2017.
1.8 Matrices.
3.5 Perform Basic Matrix Operations Algebra II.
Presentation transcript:

1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.

Problem: Guessing Birth Date 2 The program can guess your birth date. Run to see how it works. GuessBirthDate

Assignment Write a function called odd_index that takes a matrix, M, as input argument and returns a matrix that contains only those elements of M that are in odd rows and columns. In other words, it would return the elements of M at indices (1,1), (1,3), (1,5), …, (3,1), (3,3), (3,5), …, etc. Note that both the row and the column of an element must be odd to be included in the output. The following would not be returned: (1,2), (2,1), (2,2) because either the row or the column or both are even. As an example, if M were a 5- by-8 matrix, then the output must be 3-by-4 because the function omits rows 2 and 4 of M and it also omits columns 2, 4, 6, and 8 of M. 3

In the previous lectures 4  Matlab Windows (workspace, m-file,…)  Working with Arrays  One-Dimensional Array  Two-Dimensional Array  Elements of Arrays  Built-in Functions for Arrays

Agenda 5  Mathematical Operations with Arrays  Addition and Subtraction.  Multiplication.  Division: solving systems of equations  Built-in functions to analyze arrays  Element by element operations  Generating random values.

6  Matlab has two ways: 1)following linear algebra rules: - Uses the standard symbols: ( *,/,^ ) 2)Element-by-element operations: -Uses the symbols with a period: (. *,./,.^ ) - These two ways are independent and have totally different applications. Operations with Arrays

7  The operations + and – are applied where:  Arrays have identical size.  A scalar value is added/subtracted to/from an array. Addition and Subtraction

8

9

10  If A and B are two matrices, the operation A*B can be carried out only if the number of columns in matrix A is equal to the number of rows in matrix B. Multiplication

11 Multiplication

12 Multiplication

13 Multiplication

14  We will not care about the linear algebra rules of arrays division.  We just study the application of such operation in solving a system of equations.  For example: a system of three equations Division

15  Equation solving (using left division):  We can also use the inverse: - To calculate the inverse: Division or

16 Array inverse

17 Array inverse

18 Systems of three equations Solution: First: write the equations in matrix notation:

19 Systems of three equations Solution: Second: write Matlab commands:

20 Built-in Function to Analyze Arrays

21 Built-in Function to Analyze Arrays

22 Built-in Function to Analyze Arrays

23 ELEMENT-BY-ELEMENT OPERATIONS  Useful when we need to perform some mathematical operation (function) over many quantities.

24 ELEMENT-BY-ELEMENT OPERATIONS

25  Application: verify a function at different values. ELEMENT-BY-ELEMENT OPERATIONS

26  This is useful in the simulation of many physical processes and engineering applications. GENERATION OF RANDOM NUMBERS The rand command: generates uniformly distributed random numbers with values between 0 and 1.

27  Generating random values in a specific range (a,b): GENERATION OF RANDOM NUMBERS

28 GENERATION OF RANDOM NUMBERS  Generating random integers : The randi command: generates uniformly distributed random integers

29 GENERATION OF RANDOM NUMBERS  Generating random integers :

30 GENERATION OF RANDOM NUMBERS  Generating normally distributed random values :

31 GENERATION OF RANDOM NUMBERS  Generating normally distributed random values : controlling the standard deviation and mean by multiplying the number generated by the randn function by the desired standard deviation, and adding the desired mean.

32 Three forces are applied to a bracket as shown. Determine the total (equivalent) force applied to the bracket. (A force is a vector (a physical quantity that has a magnitude and direction) Example

33 Example solution  In order to use Matlab we have first to state all necessary equations and values !. where F is the magnitude of the force and θ is its angle relative to the x axis, F x and F y are the components of F in the directions of the x and y axes, i and j are unit vectors. If F x and F y are known, then F and θ can be determined by: The total (equivalent) force applied on the bracket is obtained by adding the forces that are acting on the bracket.

34 Example solution m-file:

35 Example solution Result: (in Command Window)

Material & problems 36  We have covered Chapter 3 from Gilat.  Problems you can try: Sample Problem 3-5 (page 85), 1-- 4, 12,13,23,27,31,32