1 / 15

Introduction to MATLAB

Introduction to MATLAB. CBE 502 Mathematical Methods of Engineering Analysis. Where to get MATLAB. Princeton Software : Office of Information Technology (OIT) http:// www.princeton.edu /software/licenses/software/ matlab /. What is MATLAB.

dwayne
Télécharger la présentation

Introduction to MATLAB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis

  2. Where to get MATLAB • Princeton Software : Office of Information Technology (OIT) • http://www.princeton.edu/software/licenses/software/matlab/

  3. What is MATLAB • High level language useful for technical computing with extensive library of mathematical and graphical subroutines • Stands for MATrixLABoratory

  4. MATLAB Desktop

  5. MATLAB Introduction • Creating Matrices • A=[1,2,3;4,5,6;7,8,9]; • Will give a 3 X 3 matrix • A= 1 2 3 4 5 6 7 8 9 • Very easy to access/modify each element A(i,j)

  6. MATLAB Introduction • zeros(m, n):matrix with all zeros • ones(m, n): matrix with all ones. • eye(m, n): the identity matrix • rand(m, n): uniformly distributed random • randn(m, n): normally distributed random • magic(m): square matrix whose elements have the same sum, along the row, column and diagonal.

  7. MATLAB Introduction • Colon Notation ‘:’ • Generating Vector • Step Size • Access to part of Matrix • ‘end’ Notation

  8. MATLAB Introduction • Operators • ^:exponentiation • *: multiplication • /: division • \: left division. The operation A\Bis effectively the same as INV(A)*B, although left division is calculated differently and is much quicker. • +: addition • -: subtraction • Pay attention to size of the arrays

  9. Relational/Logical Operator • == Equal to • ~= Not equal to • < Strictly smaller • > Strictly greater • <= Smaller than or equal to • >= Greater than equal to • & And operator • | Or operator

  10. MATLAB Introduction • Element by Element .^ , .* , ./ • Different from Matrix Operation • Flow Controls • If, else, for , while , break.. • M File • text file containing program to run

  11. Built In Functions • mean(A):mean value of a vector • max(A), min (A): maximum and minimum. • sum(A): summation. • sort(A): sorted vector • median(A): median value • std(A): standard deviation. • det(A) : determinant of a square matrix • dot(a,b): dot product of two vectors • Cross(a,b): cross product of two vectors • Inv(A): Inverse of a matrix A

  12. Some Useful/Interesting MATLAB Commands • who List known variables • whos List known variables plus their size • help >> help sqrt Help on using sqrt • lookfor >> lookforsqrt Search keyword sqrt in m-files • what >> what a: List MATLAB files in a: • clear Clear all variables from work space • clear x y Clear variables x and y from work space • clc Clear the command window • any (x) returns 1 if any element of x is nonzero • all (x) returns 1 if all elements of x are nonzero • isnan (x) returns 1 at each NaN in x • isinf (x) returns 1 at each infinity in x • finite (x) returns 1 at each finite value in x

  13. 2D Plots • Important Functions • plot , hold , title , xlabel, ylabel , legend • Sub plots , saveas ,

  14. Examples • MATLAB.. Here we come !!

  15. Keep on exploring MATLAB .. • May the Coding force be with you • Thanks..

More Related