1. Trang chủ
  2. » Công Nghệ Thông Tin

introduction to matlab ppt

36 273 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 36
Dung lượng 184 KB

Nội dung

Introduction to MATLAB MATLAB in Science, Engineering, and Mathematics Instruction John Sebeson DeVry University January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 What is MATLAB?  MATLAB stands for MATrix LABoratory.  MATLAB is a high-performance language for technical computing.  Math and computation  Algorithm development (optimized for DSP)  Data acquisition  Modeling, simulation, and prototyping  Data analysis, exploration, and visualization  Scientific and engineering graphics  Application development, including graphical user interface building January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 Why Learn and Use MATLAB?  Heavily used in EET/CET courses with DSP content (CET311, EET350, EET453)  Extensive built-in commands for scientific and engineering mathematics  Easy way to generate class demonstrations and test examples  Simple and intuitive programming for more complex problems  Standard and widely-used computational environment with many features, extensions, and links to other software. January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 MATLAB in DSP Product Development Develop and Test Algorithms in MATLAB SIMULINK Simulation Code Composer DSP Processor Platform MATLAB + PC = DSP Processor!! (just less efficient) January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 Why Learn MATLAB (and DSP)?  Digital Signal Processing (DSP) is the dominant technology today, and into the future, for small-signal electronic systems (i.e., just about everything)  MATLAB has become one of the standard design environments for DSP engineering  Our students need to be literate and skilled in this environment: knowledgeable in both DSP and MATLAB January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 How Can I Learn MATLAB?  Keep a copy of this presentation for reference (available on my Web Page)  Get MATLAB loaded on your PC  Read the “Getting Started” Users Guide at the MathWorks web site  Study some of the built-in help files and demos  Dive right in and use it! January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 This Presentation  The MATLAB System  The basics of MATLAB computation  The basics of MATLAB graphing  The basics of MATLAB programming  Various course examples  Mathematics  Electronics  Physics  Signal Processing(*) January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 The MATLAB System  Development Environment.  MATLAB desktop  Editor and debugger for MATLAB programs (“m-files”)  Browsers for help, built-in and on-line documentation  Extensive demos  The MATLAB Mathematical Function Library.  Elementary functions, like sum, sine, cosine, and complex arithmetic  More sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and fast Fourier transforms.  “Toolboxes” for special application areas such as Signal Processing  The MATLAB Language.  “Programming in the small" to rapidly create quick and dirty throw-away programs, or  “Programming in the large" to create large and complex application programs.  Graphics.  2D and 3D plots  Editing and annotation features  The MATLAB Application Program Interface (API).  A library that allows you to write C and Fortran programs that interact with MATLAB. January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 MATLAB Development Environment (Workspace) January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 MATLAB “Help” Utilities  MATLAB is so rich that ‘help’ is essential  Command name and syntax  Command input/output parameters  Usage examples  Help command  help command_name  help [partial_name] tab  Help documents  Demos [...].. .MATLAB Function Library (A Subset) matlab\ general matlab\ ops matlab\ lang matlab\ elmat matlab\ elfun matlab\ specfun matlab\ matfun matlab\ datafun matlab\ polyfun matlab\ funfun matlab\ sparfun matlab\ scribe matlab\ graph2d matlab\ graph3d matlab\ specgraph matlab\ graphics January 18, 2005 - General purpose commands - Operators and special characters - Programming language... Computation: Basic Operations  Array manipulation (Magic Square example)   Array, vector, and scalar operators    Sum, diag, transpose, colon operator, indexing Matrix and vector addition and multiplication Element-by-element operations Variable statements and definitions January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 MATLAB Plotting and Graphics       Rich set of commands for 2D and 3D plotting... 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Basic MATLAB Programming  Scripts        String of MATLAB commands Stored as m-file (*.m) Use variables from command line Variables have names consistent with script variable names Used for “quick and dirty” programs Example: “dydx_script” Functions        String of MATLAB commands Stored as m-file (*.m) Use variables as function parameters... time factorial - Factorial function January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 The MATLAB Language (M-file example) function one_period(amp,freq,phase) % ONE_PERIOD(AMP,FREQ,PHASE) % This function plots one period of a sine wave with a given amplitude, % frequency (in Hz), and phase ( in degrees) T=1000/freq; % Compute the period in ms t=0:T/100:T; % Define a 100 point ms time vector 1 period... 2005 J M Sebeson - DeVry Uni versity © 2005 Basic MATLAB Computation: Representation of Numbers and Variables  MATLAB operates on n row by m column matrices:  A n x m quantity is an array [8 3 4  6 7 2] A 1 x m or a n x 1 quantity is a vector [8  1 5 9 1 6] A 1 x 1 quantity is a scalar [8] January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Basic MATLAB Computation: Basic Operations  Array manipulation... DeVry Uni versity © 2005 MATLAB Graphics: 2D Functions (Physics Example) January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 MATLAB Graphics: 2D Functions (Physics Example) Planck Radiation Law 3500 kilowatts/sq.meter-micron 3000 3000 K 2700 K 2500 K 2500 2000 1500 1000 500 0 0 January 18, 2005 1 2 3 4 5 6 wavelength microns 7 J M Sebeson - DeVry Uni versity © 2005 8 9 10 MATLAB Graphics: 3D Functions... Natural logarithm of real number realsqrt - Square root of number greater than or equal to zero sqrt - Square root nthroot - Real n-th root of real numbers nextpow2 - Next higher power of 2 January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Some Specialized Functions Number theoretic functions factor - Prime factors isprime - True for prime numbers primes - Generate list of prime numbers gcd - Greatest... “num2str” for variable formatting Use of parameter-controlled data input loops “fft_plot”   Use of MATLAB functions as subroutines Use of “nargin” test and branch January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Mathematics Example: Polynomial Algebra (Convolution Operator)  Polynomial products and factoring: ( x 2 + 3 x + 2)( x 3 + 5 x 2 + 4 x + 4) = x 5 + 8 x 4 + 21x 3 + 26 x 2 + 20 x + 8 >> p1=[1,3,2];... 2 y − 3 z = −3 4 y + 3 z = −2   x − y + 9 z = 60 A*S=B MATLAB Code: >> A=[5,-2,-3;0,4,3;1,-1,9]; >> B=[-3,-2,60]'; % Note vector transpose (‘) >> S=linsolve(A,B) S= 1.0000 -5.0000 6.0000 January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Mathematics Example: Polynomial Roots  Find the roots of the following system: y = 12 x 2 − x − 8  MATLAB code: >> roots([12 -1 -8]) ans = 0.8592 -0.7759 January... of a Trajectory  Problem: A football kicker can give the ball an initial speed of 25 m/s Within what two elevation angles must he kick the ball to score a field goal from a point 50 m in front of goalposts whose horizontal bar is 3.44 m above the ground? January 18, 2005 J M Sebeson - DeVry Uni versity © 2005 Physics Example: Field Goal Problem Solution: The general solution is the “trajectory equation.” . Introduction to MATLAB MATLAB in Science, Engineering, and Mathematics Instruction John Sebeson DeVry University January 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 What is MATLAB?  MATLAB. Uni versity © 2005 MATLAB Function Library (A Subset) matlab general - General purpose commands. matlab ops - Operators and special characters. matlab lang - Programming language constructs. matlab elmat. 18, 2005 J. M. Sebeson - DeVry Uni versity © 2005 The MATLAB System  Development Environment.  MATLAB desktop  Editor and debugger for MATLAB programs (“m-files”)  Browsers for help, built-in

Ngày đăng: 24/10/2014, 23:30

TỪ KHÓA LIÊN QUAN