ENG 1181 1 College of Engineering Engineering Education Innovation Center 1 Array Operations in MATLAB 1.Types of Matrix arithmetic 2.Dot operators Mathematical.

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

Maths for Computer Graphics
Arrays Revisited Selim Aksoy Bilkent University Department of Computer Engineering
EGR 106 – Week 4 – Math on Arrays
Week 3 Last week Vectors Array Addressing Mathematical Operations Array Multiplication and Division Identity Matrix Inverse of a Matrix Element by Element.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
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.
4.2 Adding and Subtracting Matrices 4.3 Matrix Multiplication
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.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Chapter 10 Review: Matrix Algebra
ECON 1150 Matrix Operations Special Matrices
Equation --- An equation is a mathematical statement that asserts the equality of twomathematicalstatement expressions. An equation involves an unknown,
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Review for Chapter 4 Important Terms, Symbols, Concepts 4.1. Systems of Linear Equations in Two Variables.
THU, JAN 8, 2015 Create a “Big Book of Matrices” flip book using 4 pages. Do not make your tabs big! BIG BOOK OF MATRICES What is a Matrix? Adding & Subtracting.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
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,
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Learner’s Guide to MATLAB® Chapter 2 : Working with Arrays.
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Lecture 28: Mathematical Insight and Engineering.
Unit 3: Matrices.
Algebra 3: Section 5.5 Objectives of this Section Find the Sum and Difference of Two Matrices Find Scalar Multiples of a Matrix Find the Product of Two.
Linear Algebra 1.Basic concepts 2.Matrix operations.
Lesson 11-1 Matrix Basics and Augmented Matrices Objective: To learn to solve systems of linear equation using matrices.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Copyright © Cengage Learning. All rights reserved. 7 Linear Systems and Matrices.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
1 ECE 1304 Introduction to Electrical and Computer Engineering Section 1.7 Linear Algebra with MATLAB.
Matrix Algebra Section 7.2. Review of order of matrices 2 rows, 3 columns Order is determined by: (# of rows) x (# of columns)
Array Operations ENGR 1181 MATLAB 4.
Algebra Matrix Operations. Definition Matrix-A rectangular arrangement of numbers in rows and columns Dimensions- number of rows then columns Entries-
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
3.5 Perform Basic Matrix Operations Add Matrices Subtract Matrices Solve Matric equations for x and y.
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)
To add, subtract, multiply, and divide, absolutely follow the mathematical rules. 1. All the rules 2. The element-per-element operator 3. Ex1: graphing.
Array and Matrix Operations EE 201 Fall  Achieve Comprehension LOL of Array and Matrix Operations. Class Learning Objectives 2.
Warm-UP A = 7-310B = C =7-4Find:A 22 and C 31 97Find: the dimensions of each -88 Matrix Find: A + B and B – A and C + B.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
Ch. 12 Vocabulary 1.) matrix 2.) element 3.) scalar 4.) scalar multiplication.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © Cengage Learning. All rights reserved. 7 Matrices and Determinants.
An Introduction to Matrix Algebra Math 2240 Appalachian State University Dr. Ginn.
College Algebra Chapter 6 Matrices and Determinants and Applications
MTH108 Business Math I Lecture 20.
Linear Algebraic Equations and Matrices
12-1 Organizing Data Using Matrices
Chapter 7 Matrix Mathematics
Linear Algebraic Equations and Matrices
Matrix Operations SpringSemester 2017.
Section 7.4 Matrix Algebra.
7.3 Matrices.
3.5 Perform Basic Matrix Operations
Chapter 4 Systems of Linear Equations; Matrices
Chapter 4 Matrices & Determinants
1.8 Matrices.
Matrix Operations Ms. Olifer.
Matrix Operations SpringSemester 2017.
1.8 Matrices.
3.5 Perform Basic Matrix Operations Algebra II.
Presentation transcript:

ENG College of Engineering Engineering Education Innovation Center 1 Array Operations in MATLAB 1.Types of Matrix arithmetic 2.Dot operators Mathematical Operations with Arrays : Chapter 3

ENG Types of Matrix Arithmetic There are two types of matrix arithmetic Matrix math is used in Linear Algebra to solve simultaneous equations (MATLAB text Ch. 3.2 and beyond the scope of this course) We will only introduce element-by-element arithmetic, e.g. If A = [a b c] and B = [x y z], then A + B = [a+x b+y c+z]

ENG Types of array arithmetic There are only six cases where matrix math and element-by-element arithmetic differ A*B A/B A^B A^s s^A s/A For these cases, the standard operator has been chosen to represent matrix arithmetic, so we need a new symbol for element-by element arithmetic (dot operators) A.*B A./B A.^B A.^s s.^A s./A If A and B are matrices and s is a scalar,

ENG The vectors must be the same size. Element-by-element operations for row vectors: If:a = [a1 a2 a3] and b = [b1 b2 b3] Then: a.* b = [a 1 * b 1 a 2 * b 2 a 3 * b 3 ] a./ b = [a 1 / b 1 a 2 / b 2 a 3 / b 3 ] a.^ b = [a 1 ^b 1 a 2 ^b 2 a 3 ^b 3 ] a.^2 = [a 1 ^2 a 2 ^2 a 3 ^2] 2./a = [2/a 1 2/a 2 2/a 3 ] Examples of Dot Operators

ENG Element-by-element operations for matrices: Then: Given:and Examples of Dot Operators

ENG MATRIX ELEMENT-BY-ELEMENT EXAMPLES >> A = [1, 2, 3; 4, 5, 6] A = >> B = [1, 2, -1; 2, -2, 5] B = >> A.* B ans = >> A./ B ans = >> B.^ 3 ans =

ENG Dot Operators If you forget a dot, when one is required, you will either get a cryptic error message (involving matrix dimensions) or you will get the wrong answer For the following operations: s+A, s-A, A-s, A+B, A-B, s*A, A/s matrix math is the same as element-by- element arithmetic, so dot operators are optional.

ENG SCALAR-ARRAY ADDITION AND SUBTRACTION >> M = M = >> a = s + M a = >> b = s - M b = >> c = M - s c = The scalar operates on each element in the array. For example, given the following matrix M and the scalar s = 2 we would get the following results for addition and subtraction

ENG SCALAR-ARRAY MULTIPLICATION AND DIVISION the scalar operates on each element in the array For example, given the same matrix M and scalar s = 2 we would get the following results for multiplication and division >> M = M = >> d = s * M d = >> d = M / s d =

ENG ARRAY-ARRAY ADDITION AND SUBTRACTION The arrays being used in the operation must have the same size. The sum (difference) of two arrays is obtained by adding (subtracting) corresponding array elements, resulting in a new array of the same size. >> A = [1 2; 3 4] A = >> B = [1 -1; 2 0] B = >> C = A + B C = >> A - B ans =

ENG CALCULATING THE VALUE OF A FUNCTION For the function: calculate y for z = 1, 3, 5, 7, 9, 11, SOLUTION USING MATLAB: >> z = [1: 2: 15] z = Create a vector z with seven elements. Where do you have operations between vectors that need a dot operator? >> y = (z.^ * z)./ (4 * z.^ ) y =

ENG Element-by-Element Calculations NOTE: Even though the calculation is written only one time in the previous example, MATLAB iterates through all elements of z (Element-by-Element) and calculates a corresponding number of elements of solution array y.

ENG SOME USEFUL BUILT-IN ARRAY FUNCTIONS MATLAB has many built-in functions that can be used with arrays. Some of them are (A is a vector): max(A)Returns the largest element in A min(A)Returns the smallest element in A mean(A)Returns the average value of the elements in A sum(A)Returns the sum of the elements of A length(A)Returns the number of elements in A sort(A)Sorts the elements of A The Help window gives information about many other functions

ENG EXAMPLES OF BUILT IN FUNCTIONS >> sum(A) ans = 48 >> length(A) ans = 6 >> sort(A) ans = >> A = [ ] A = >> max(A) ans = 14 >> min(A) ans = 2 >> mean(A) ans =

ENG APPLICATION Element-by-element calculations are useful in processing data and in calculating the value of a mathematical function at many points. EXAMPLE: The coefficient of friction μ is determined by measuring the force F required to move a mass μ: μ = F / (mg) g = 9.81 m/s 2 The results from measuring F in five tests are given in the table. Determine the coefficient of friction in each test, and the average from all tests. m Ffriction 69 Mass: m (kg) Force: F (N)

ENG >> mass = [ ]; >> force = [ ]; >> mu = force./ (9.81 * mass) mu = >> mu_ave = mean(mu) meu_ave = COEFFICIENT OF FRICTION USING MATLAB 69 Create the mass vector. Create the force vector Calculate mu for each mass-force pair, using element-by-element calculations. Determine the average of the elements in the vector mu by using the function mean().