Matlab Primer - Matlab Primer Matlab is the abbreviation...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Matlab Primer Matlab is the abbreviation for Matrix Laboratory, a matrix processing language that is applicable to scientific and engineering data processing. This versatile programming language allows you to easily create your own special functions and programs known as M-Files. A specialized collection of M-Files for working on a particular class of problems is known as Toolbox. Matrices and Vectors In Matlab, A row vector A having 3 elements is defined as follows: >>A = [0 2 3] A column matrix is given by >>A = [0; 2; 3] The transpose of A is given by A’. The 3 x 3 matrices B and C can be entered as follows: >>B = [2 4 5; 2 -9 0; 7 5 2] >>C= [1 -2 3; 2 1 2; 8 9 -1] The product of two matrices B and C (if conformable for multiplication) is given by B*C. Note that B*C is not equal to C*B. For element by element multiplication a dot is used after the first matrix, viz. B.*C Matrix operations, array operations The following matrix operations are available in MATLAB: + addition - subtraction * multiplication ^ power ' transpose \ left division / right division Array operations. The matrix operations of addition and subtraction already operate entry-wise but the other matrix operations given above do not-they are matrix operations. It is important to observe that these other operations,
Background image of page 1

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

View Full DocumentRight Arrow Icon
* , ^ , \ , and /, can be made to operate entry-wise by preceding them by a period. For example, either [1,2,3,4].*[1,2,3,4] or [1,2,3,4].^2 will yield [1,4,9,16]. Try it. This is particularly useful when using Matlab graphics. Matrix building functions Convenient matrix building functions are eye(10) identity matrix zeros(10) matrix of zeros ones(10) matrix of ones diag(A) returns diagonal M.E. as vector triu(A) upper triangular part of a matrix tril(A) lower triangular part of a matrix rand(10) randomly generated matrix hilb(5) Hilbert matrix magic(5) magic square toeplitz see help toeplitz For example, zeros(m,n) produces an m-by-n matrix of zeros and zeros(n) produces an n-by-n one; if A is a matrix, then zeros(A) produces a matrix of zeros of the same size as A . If x is a vector, diag(x) is the diagonal matrix with x down the diagonal; if A is a
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2011 for the course STATISTICS 101 taught by Professor Nazim during the Spring '10 term at Qatar University.

Page1 / 11

Matlab Primer - Matlab Primer Matlab is the abbreviation...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online