MATLAB 程式設計 Learning Linear Algebra 方煒 台大生機系. MATLAB 程式設計 Vector Products, Dot and Cross a=[1,2,3];b=[3,2,1]; C=a*b D=a.*b E=dot(a,b) F=cross(a,b)

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

OCE301 Part II: Linear Algebra lecture 4. Eigenvalue Problem Ax = y Ax = x occur frequently in engineering analysis (eigenvalue problem) Ax =  x [ A.
Refresher: Vector and Matrix Algebra Mike Kirkpatrick Department of Chemical Engineering FAMU-FSU College of Engineering.
Mathematics. Matrices and Determinants-1 Session.
3_3 An Useful Overview of Matrix Algebra
Ch 7.2: Review of Matrices For theoretical and computation reasons, we review results of matrix theory in this section and the next. A matrix A is an m.
1 Neural Nets Applications Vectors and Matrices. 2/27 Outline 1. Definition of Vectors 2. Operations on Vectors 3. Linear Dependence of Vectors 4. Definition.
Boot Camp in Linear Algebra Joel Barajas Karla L Caballero University of California Silicon Valley Center October 8th, 2008.
Matrix Approach to Simple Linear Regression KNNL – Chapter 5.
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
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.
MATRICES MATRIX OPERATIONS. About Matrices  A matrix is a rectangular arrangement of numbers in rows and columns. Rows run horizontally and columns run.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
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.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Linear Algebra Review By Tim K. Marks UCSD Borrows heavily from: Jana Kosecka Virginia de Sa (UCSD) Cogsci 108F Linear.
Compiled By Raj G. Tiwari
ECON 1150 Matrix Operations Special Matrices
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
Matlab tutorial course Lesson 2: Arrays and data types
Presentation on Matrices and some special matrices In partial fulfillment of the subject Vector calculus and linear algebra ( ) Submitted by: Agarwal.
Basic Operations MultiplicationDeterminants Cramer’s RuleIdentityInverses Solving Systems of equations APPENDIX.
Matrix Algebra. Quick Review Quick Review Solutions.
A rectangular array of numbers (we will concentrate on real numbers). A nxm matrix has ‘n’ rows and ‘m’ columns What is a matrix? First column First row.
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.
Statistics and Linear Algebra (the real thing). Vector A vector is a rectangular arrangement of number in several rows and one column. A vector is denoted.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
8.1 Matrices & Systems of Equations
Lecture 28: Mathematical Insight and Engineering.
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.
Matrices. Definitions  A matrix is an m x n array of scalars, arranged conceptually as m rows and n columns.  m is referred to as the row dimension.
Linear algebra: matrix Eigen-value Problems Eng. Hassan S. Migdadi Part 1.
Prepared by Deluar Jahan Moloy Lecturer Northern University Bangladesh
Fundamentals of Engineering Analysis
Chapter 6 Systems of Linear Equations and Matrices Sections 6.3 – 6.5.
Eigenvalues The eigenvalue problem is to determine the nontrivial solutions of the equation Ax= x where A is an n-by-n matrix, x is a length n column.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
Introduction to Linear Algebra Mark Goldman Emily Mackevicius.
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
Review of Matrix Operations Vector: a sequence of elements (the order is important) e.g., x = (2, 1) denotes a vector length = sqrt(2*2+1*1) orientation.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Selected Algebraic System Examples from Lectures.
STROUD Worked examples and exercises are in the text Programme 5: Matrices MATRICES PROGRAMME 5.
Linear System of Simultaneous Equations Warm UP First precinct: 6 arrests last week equally divided between felonies and misdemeanors. Second precinct:
STROUD Worked examples and exercises are in the text PROGRAMME 5 MATRICES.
Boot Camp in Linear Algebra TIM 209 Prof. Ram Akella.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
2.1 Matrix Operations 2. Matrix Algebra. j -th column i -th row Diagonal entries Diagonal matrix : a square matrix whose nondiagonal entries are zero.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
College Algebra Chapter 6 Matrices and Determinants and Applications
MTH108 Business Math I Lecture 20.
MATRICES.
Linear Algebra Lecture 2.
Review of Matrix Operations
Copyright © 2009 Dan Nettleton
Warm-up a. Solve for k: 13 −5
MATRICES MATRIX OPERATIONS.
RECORD. RECORD Gaussian Elimination: derived system back-substitution.
2. Matrix Algebra 2.1 Matrix Operations.
MATRICES MATRIX OPERATIONS.
Eigenvalues and Eigenvectors
Basics of Linear Algebra
MATLAB 程式設計 Learning Loops and Logic
Multiplication of Matrices
MATRICES MATRIX OPERATIONS.
MATRICES MATRIX OPERATIONS.
Presentation transcript:

MATLAB 程式設計 Learning Linear Algebra 方煒 台大生機系

MATLAB 程式設計 Vector Products, Dot and Cross a=[1,2,3];b=[3,2,1]; C=a*b D=a.*b E=dot(a,b) F=cross(a,b)

MATLAB 程式設計 Ex7_1 Solve a Linear System A=[ 1, 0,1;-1, 1,1;1,-1,1 ]; b=[4;4;2]; % now solve for x x=A\b %we obtain [1;2;3]

MATLAB 程式設計 Ex7_2 Max and Min x=0:.01:5; y=x.*exp(-x.^2); % take a look at the function so we know what it looks like plot(x,y) % find the max and min ymin=min(y) ymax=max(y) % find the max and min along with the array indices imax and imin % where they occur [ymin,imin]=min(y) [ymax,imax]=max(y)

MATLAB 程式設計 Ex7_3 Matrix Inverse A=[1,0,-1;-1,1,1;1,-1,1] % load C with the inverse of A C=inv(A) % verify by matrix multiplication % that A*C is the identity matrix A*C

MATLAB 程式設計 Ex7_4 Transpose and Hermitian Conjugate If your matrices are real, then there is no difference between these two commands %find the transpose of the matrix A A. ’ %find the Hermitian conjugate of matrix A A ’ [1,2,3] [1,2,3] ’ [4;5;6] [4;5;6] ’

MATLAB 程式設計 Ex7_5a Special Matrices % eye: % load I with the 4x4 identity matrix (the programmer who invented this % syntax must have been drunk) I=eye(4,4) % zeros: % load Z with a 5x5 matrix full of zeros Z=zeros(5,5) % ones: % load X with a 3x3 matrix full of ones X=ones(3,3) % rand: % load Y with a 4x6 matrix full of random numbers between 0 and 1 % The random numbers are uniformly distributed on [0,1] Y=rand(4,6) % And to load a single random number just use r=rand % randn: % load Y with a 4x6 matrix full of random numbers with a Gaussian % distribution with zero mean and a variance of 1 Y=randn(4,6)

MATLAB 程式設計 Ex7_6 Determinant and Ex7_7 Norm Ex7_6 Determinant %Find the determinant of a square matrix this way det(A) Ex7_7 Norm of Vector (Magnitude) %Matlab will compute the magnitude of a vector a %(the square root of the sum of the squares of its components) %with the norm command a=[1,2,3] norm(a)

MATLAB 程式設計 Ex7_8 Sum the Elements %For arrays the command sum adds up the elements of the array: % calculate the sum of the squares of the reciprocals of the % integers from 1 to 10,000 n=1:10000; sum(1./n.^2) % compare this answer with the sum to infinity, which is pi^2/6 ans-pi^2/6 For matrices the sum command produces a row vector which is made up of the sum of the columns of the matrix. A=[1,2,3;4,5,6;7,8,9] sum(A)

MATLAB 程式設計 Ex7_9 Eigenvalues and Eigenvectors %build a column vector containing eigenvalues of the matrix A in previous section use E=eig(A) %To build a matrix V whose columns are the eigenvectors of the matrix A %and another matrix D whose diagonal elements are the eigenvalues %corresponding to the eigenvectors in V use [V,D]=eig(A) % to select the 3rd eigenvector and load it into a column vector use v3=V(:,3) % i.e., select all of the rows (:) in column 3

MATLAB 程式設計 more stuff help svd help QR help LU help rref help rcond help cond