Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer.

Slides:



Advertisements
Similar presentations
2.3 Modeling Real World Data with Matrices
Advertisements

CSNB143 – Discrete Structure
Matrix Multiplication To Multiply matrix A by matrix B: Multiply corresponding entries and then add the resulting products (1)(-1)+ (2)(3) Multiply each.
Maths for Computer Graphics
Solving systems using matrices
Intro to Matrices Don’t be scared….
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Determinants 2 x 2 and 3 x 3 Matrices. Matrices A matrix is an array of numbers that are arranged in rows and columns. A matrix is “square” if it has.
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer.
Algebra 2: Lesson 5 Using Matrices to Organize Data and Solve Problems.
ECON 1150 Matrix Operations Special Matrices
Euclidean m-Space & Linear Equations Row Reduction of Linear Systems.
1 M ATLAB Short Course. History of Calculator 2 3 Introduction to Matlab Matlab is short for Matrix Laboratory Matlab is also a programming language.
Objectives  Add two matrices  Subtract two matrices  Multiply a matrix by a constant  Multiply two matrices.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
10.4 Matrix Algebra 1.Matrix Notation 2.Sum/Difference of 2 matrices 3.Scalar multiple 4.Product of 2 matrices 5.Identity Matrix 6.Inverse of a matrix.
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
13.1 Matrices and Their Sums
Company LOGO Chapter 1: Matrix, Determinant, System of linear equations Module 1: Matrix Natural Science Department Example 1: The following rectangular.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Lec-10 Manipulations of Matlab Matrices. Built-in functions The chapter will be covered quickly There are quite a few built-in functions in MATLAB – If.
Prepared by Deluar Jahan Moloy Lecturer Northern University Bangladesh
Polynomials UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Matrix Algebra Section 7.2. Review of order of matrices 2 rows, 3 columns Order is determined by: (# of rows) x (# of columns)
8.2 Operations With Matrices
Matrix Operations.
3.4 Solution by Matrices. What is a Matrix? matrix A matrix is a rectangular array of numbers.
1.3 Matrices and Matrix Operations. A matrix is a rectangular array of numbers. The numbers in the arry are called the Entries in the matrix. The size.
Matrices and Matrix Operations. Matrices An m×n matrix A is a rectangular array of mn real numbers arranged in m horizontal rows and n vertical columns.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Section 4.3 – Multiplying Matrices. MATRIX MULTIPLICATION 1. The order makes a difference…AB is different from BA. 2. The number of columns in first matrix.
Section – Operations with Matrices No Calculator By the end of this lesson you should be able to: Write a matrix and identify its order Determine.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
Precalculus Section 14.1 Add and subtract matrices Often a set of data is arranged in a table form A matrix is a rectangular.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
The Algebra of Matrices Matrix: An array of numbers. Matrix Name (Capital Letter) Matrix Size (row x column) Columns Rows Elements: a rc a 22 = 4.
Ch. 12 Vocabulary 1.) matrix 2.) element 3.) scalar 4.) scalar multiplication.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
Matrices. Matrix A matrix is an ordered rectangular array of numbers. The entry in the i th row and j th column is denoted by a ij. Ex. 4 Columns 3 Rows.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
13.4 Product of Two Matrices
Sections 2.4 and 2.5 Matrix Operations
12-1 Organizing Data Using Matrices
College Algebra Chapter 6 Matrices and Determinants and Applications
Matrix Multiplication
Matrix Operations.
Matrix Operations SpringSemester 2017.
Dr. Ameria Eldosoky Discrete mathematics
Section 7.4 Matrix Algebra.
Matrix Algebra.
Matrices Elements, Adding and Subtracting
MATRICES MATRIX OPERATIONS.
Section 2.4 Matrices.
Objectives Multiply two matrices.
Matrices and Matrix Operations
Matrix Algebra.
Matrix Operations Chapter 4, Sections 1, 2, 3.
3.5 Perform Basic Matrix Operations
3.6 Multiply Matrices.
1.8 Matrices.
Matrix Operations SpringSemester 2017.
CS100A Lecture 21 Previous Lecture This Lecture
1.8 Matrices.
3.5 Perform Basic Matrix Operations Algebra II.
Presentation transcript:

Vlachopoulos Georgios Lecturer of Computer Science and Informatics Technological Institute of Patras, Department of Optometry, Branch of Egion Lecturer of Biostatistics Technological Institute of Patras, Department of Physiotherapy, Branch of Egion Matrices in Matlab

Vlachopoulos Georgios  Matlab  (Matrix Laboratory) ◦ A powerful tool to handle Matrices

Vlachopoulos Georgios  A=[2,4,7]  B=[1:1:10]  C=[10:3:40]  D=[30:-3:0]  D1=[1:pi:100]  Length(D1)  D2=linspace(2,10,20)

 E=[1,2,3↲  4,5,6]  F=[1,2,3;4,5,6] G=[1;2;3] H=[1,2,3; 4,5] Vlachopoulos Georgios

X=2; H=[x,sin(pi/4), 3,2*x; sqrt(5), x^2,log(x),4] H1=[x,sin(pi/4), 3,2*x; sqrt(5), x^2,log(x),4; linspace(1,2,4)] Vlachopoulos Georgios

 Special functions zeros(2,4) zeros(2,2) zeros(2) ones(2,4) ones(2,2) ones(2) eye(2,2) eye(2) eye(2,4) Vlachopoulos Georgios

 Special functions rand (2,4) rand(2,2) rand(2) magic(3) hilb(3) Vlachopoulos Georgios

 +  -  *  /  \ .* ./ .\  ^ (base and exp)  inv  size Vlachopoulos Georgios

 Inner Product ◦ dot(array1,array2)  Cross Product ◦ cross(array1,array2) Vlachopoulos Georgios

 Every polynomial corresponds to an array with elements the coefficients of the polynomial Example f1(x)=x 2 -5x+6  f1=[1,-5,6] f2(x)=x3-5x+6  f2=[1,0,-5,6] Vlachopoulos Georgios

 Add polynomials ◦ array1+array2 ◦ If we have different order polynomials we create equal sizes arrays adding zeros on missing coefficients  Add polynomials ◦ array1-array2 ◦ If we have different order polynomials we create equal sizes arrays adding zeros on missing coefficients  Multiply polynomials ◦ conv(array1,array2)  Divide polynomials ◦ deconv(array1,array2) Vlachopoulos Georgios

 Roots of a polynomial roots(array)  Polynomial with roots the elements of the array poly(array)  First order derivative of the Polynomial polyder(array)  Value of the Polynomial p for x=a polyval(p,a) Vlachopoulos Georgios

 Examples k1=root(f1) k2=root(f2) poly(k1) kder=polyder(f2) polyval(s2,5) Vlachopoulos Georgios

 A∪B  union(array1,array2)  A∩B  intersect(array1,array2)  A∼B  setdiff(array1,array2) Example ◦ a=1:6 ◦ b=0:2:10 ◦ c=union(a,b) ◦ d=intersect(a,b) ◦ e1=setdiff(a,b) ◦ e2=setdiff(b,a) Vlachopoulos Georgios

 Unique Elements  unique(array)  Elements of A that are members of B  ismember(array1,array2) Example ◦ f1=ismember(a,b) ◦ f2=ismember(b,a) ◦ g=[1,1,2,2,3,3] ◦ h=unique(g) Vlachopoulos Georgios

 Arrays ◦ Sum of array elements  sum(array) ◦ Product of array elements  prod(array) ◦ Cumulative sum of an array elements  cumsum(array) ◦ Cumulative prod of an array elements  cumprod(array) Vlachopoulos Georgios

 Matrices ◦ Sum of elements of each matrix column  sum(matrix) or  sum(matrix,1) ◦ Sum of elements of each matrix row  sum(matrix,2) Overall sum???? Vlachopoulos Georgios

 Matrices ◦ Product of elements of each matrix column  prod(matrix) or  prod(matrix,1) ◦ Product of elements of each matrix row  prod(matrix,2) Overall product???? Vlachopoulos Georgios

 Matrices ◦ Cumulative sum per column  cumsum(matrix) or  cumsum (matrix,1) ◦ Cumulative sum per row  cumsum (matrix,2) Vlachopoulos Georgios

 Matrices ◦ Cumulative sum per column  cumprod(matrix) or  cumprod (matrix,1) ◦ Cumulative sum per row  cumprod(matrix,2) Vlachopoulos Georgios

 Matrix element  A(i,j) Example: A=[1,2,3;4,5,6] A(2,1)↲ A(2,1)=4 Vlachopoulos Georgios

Example: A=[1,2,3;4,5,6;3,2,1] B=A(1:2,2,3) y=A(:,1) Z=A(1,:) W=A([2,3],[1,3]) A(:) Vlachopoulos Georgios

 Delete elements Example ◦ Clear all; ◦ A=magic(5) ◦ A(2,: )=[] % delete second row ◦ A(:[1,4])=[] % delete columns 1 and 4 ◦ A=magic(5) ◦ A(1:3,:)=[] % delete rows 1 to 3 Vlachopoulos Georgios

 Replace Elements Example ◦ Clear all; ◦ A=magic(5) ◦ A(2,3 )=5 % Replace Element (2,3) ◦ A(3,:)=[12,13,14,15,16] % replace 3 rd row ◦ A([2,5]=[22,23,24,25,26; 32,33,34,35,36] Vlachopoulos Georgios

 Insert Elements Example ◦ Clear all; ◦ A=magic(5) ◦ A(6,:)=[1,2,3,4,5,6] ◦ A(9,:)=[11,12,13,14,15,16] Vlachopoulos Georgios