{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

matlab_matrix

# matlab_matrix - Introduction to MATLAB MATLAB Matrix...

This preview shows pages 1–12. Sign up to view the full content.

Virginia Polytechnic Institute and State University 1 of 53 Introduction to MATLAB MATLAB Matrix Manipulations Transportation Infrastructure Systems GS Dr. Antonio Trani Civil and Environmental Engineering Virginia Polytechnic Institute and State University Fall 2002

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Virginia Polytechnic Institute and State University 2 of 53 Purpose of this Section To illustrate examples of matrix manipulation in MATLAB To learn some of the basic plotting functions in MATLAB Just for the fun of learning something new ( the most important reason )
Virginia Polytechnic Institute and State University 3 of 53 Basic Matrix Manipulation Let and A = [4 3 4; 4 6 8; 3 6 6]; b = [35 22 40]'; y = A*b; Results in column vector y, y = 366 592 477 A 4 3 4 4 6 8 3 6 6 = b 35 22 40 =

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Virginia Polytechnic Institute and State University 4 of 53 Solution of Linear Equations (I) Suppose we want to solve the set of linear equations: Then in matrix form we have: 4 x 1 3 x 2 4 x 3 + + 35 = 4 x 1 6 x 2 8 x 3 + + 22 = 3 x 1 6 x 2 6 x 3 + + 40 = Ax b =
Virginia Polytechnic Institute and State University 5 of 53 Sol. of Linear Equations (II) where: , and Using MATLAB this can be solved using the operator \ \ % Solution of linear equations A = [4 3 4; 4 6 8; 3 6 6]; b = [35 22 40]';x = A\b; A 4 3 4 4 6 8 3 6 6 = x x 1 x 2 x 3 = b 35 22 40 = x A = b

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Virginia Polytechnic Institute and State University 6 of 53 Solution of Linear Equations (III) Yields the following answer for x, x = 12.0000 15.6667 -15.0000 % Another solution of the linear equations A = [4 3 4; 4 6 8; 3 6 6]; b = [35 22 40]'; x = inv(A)*b; This gives the same result taking the inverse of A
Virginia Polytechnic Institute and State University 7 of 53 Array vs Scalar MATLAB Operators (I) MATLAB differentiates between array and scalar operators Scalar operators apply to matrices Array operators have a period in front of the operand Array operations in your code should always be stated using a period bef or e the operand. For example: x = 0:0.05:8; y = sin(x^2)*exp(-x); Will not execute correctly because the manipulation of array x requires operands with a period in front (MATLAB nomenclature)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Virginia Polytechnic Institute and State University 8 of 53 Array vs. Scalar MATLAB Operators (II) The following script will execute correctly x = 0:0.05:8; y = sin(x.^2).*exp(-x); The following operations are valid and execute correcly A = [3 3 3 ; 2 2 2; 1 1 1]; c = A ^ 2 ; d = A * A ; e = A / 2 ; f = A * 3;
Virginia Polytechnic Institute and State University 9 of 53 Array Operators Use these to do basic operations on arrays of any size Operation MATLAB Operators Array multiplication .* Array power .^ Left array division .\ Right array division ./ Matrix multiplication * Matrix power ^ Matrix division / Left matrix division \

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Virginia Polytechnic Institute and State University 10 of 53 Array Manipulation Tips Always define the size of the arrays to be used in the program (static allocation) Define arrays with zero elements (defines statically array sizes and thus reduces computation time) »d=zeros(1,3) d = 0 0 0 »c=ones(1,3) c = 1 1 1
Virginia Polytechnic Institute and State University 11 of 53 Array Manipulation Tips Sample of for-loop without array pre allocation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• KATZ
• matlab, Atlantic Coast Conference, Statistical charts and diagrams, Virginia Polytechnic Institute and State University, Institute of Technology, Virginia Polytechnic Institute

{[ snackBarMessage ]}

### Page1 / 53

matlab_matrix - Introduction to MATLAB MATLAB Matrix...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online