{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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,
Image of page 1

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

View Full Document Right 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 .
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern