1 / 45

MATLAB

MATLAB. COMM2M Harry R. Erwin, PhD University of Sunderland. Resources. Higham and Higham, 2000, MATLAB Guide, SIAM. http://www.utexas.edu/math/Matlab/Manual/faq.html —source of the history presented here. MATLAB Introduction (FAQ).

wilma
Download Presentation

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. MATLAB COMM2M Harry R. Erwin, PhD University of Sunderland

  2. Resources • Higham and Higham, 2000, MATLAB Guide, SIAM. • http://www.utexas.edu/math/Matlab/Manual/faq.html—source of the history presented here.

  3. MATLAB Introduction (FAQ) • MATLAB was originally developed to be a "matrix laboratory," written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. • Since then, the software has evolved into an interactive system and programming language for general scientific and technical computation and visualization.

  4. SIMULINK (FAQ) • SIMULINK is an interactive system for the nonlinear simulation of dynamic systems. • A graphical, mouse-driven program that allows systems to be modeled by drawing a block diagram on the screen. • It can handle linear, nonlinear, continuous-time, discrete-time, multivariable, and multirate systems. • SIMULINK runs on workstations using X-Windows. • SIMULINK is fully integrated with MATLAB, and, together with MATLAB and the Control System Toolbox, forms a complete control system design and analysis environment.

  5. LAPACK • A high performance matrix processing library, commonly used in computational science. • A descendent of LINPACK • Currently integrated with MATLAB.

  6. MATLAB History (FAQ) • In the mid-1970s, Cleve Moler and several colleagues developed the FORTRAN subroutine libraries called LINPACK and EISPACK under a grant from the National Science Foundation. • LINPACK was a collection of FORTRAN subroutines for solving linear equations, while EISPACK contained subroutines for solving eigenvalue problems. • Together, LINPACK and EISPACK represented state of the art software for matrix computation.

  7. Second Phase (FAQ) • In the late 1970s, Moler, who was then chairman of the computer science department at the University of New Mexico, wanted to be able to teach students in his linear algebra courses using the LINPACK and EISPACK software. • However, he didn't want them to have to program in FORTRAN, because this wasn't the purpose of the course. • So, as a "hobby" on his own time, he started to write a program that would provide simple interactive access to LINPACK and EISPACK.

  8. Emergence of MATLAB (FAQ) • Moler named his program MATLAB, for MATrix LABoratory. • Over the next several years, when he would visit another university to give a talk, or as a visiting professor, he would end up by leaving a copy of his MATLAB on the university machines. • Within a year or two, MATLAB started to catch on by word of mouth within the applied math community as a "cult" phenomena.

  9. Professional MATLAB Development (FAQ) • In early 1983, John Little was exposed to MATLAB because of a visit Cleve made to Stanford. • Little, an engineer, recognized the potential application of MATLAB to engineering applications. • So in 1983, Little teamed up with Moler and Steve Bangert to develop a second generation, professional version of MATLAB written in C and integrated with graphics. • The MathWorks, Inc. was founded in 1984 to market and continue development of MATLAB.

  10. Basic Features of MATLAB (FAQ) • MATLAB commands are expressed in a form very similar to that used in mathematics and engineering. • For instance, b = A x, where A, b, and x are matrices, is written b = A * x . • To solve for x in terms of A and b, write x = A\b • There is no need to program matrix operations explicitly like multiplication or inversion. • Solving problems in MATLAB is much quicker than programming in a high-level language such as C or FORTRAN.

  11. Character Set • ASCII Character Set • The following are used as operators: • ! ‘ “ ( : ) , … / : ; < <= == > >= @ [..] [] % & \ ^ | >> ~ ~= • .’ .* ./ .\ .^

  12. Comments • A line beginning with %

  13. Variable Names • Case sensitive • Up to 31 characters long • Begin with a letter • Followed by letters, digits, underscores • Variables are created when they are assigned. • pi, i, and j are predefined. • To list variables use who or whos (detailed) • clear or clear var clears out the workspace

  14. Commands • Type exit or quit to quit MATLAB • Type foo to run foo.m • Terminate a command with ; to suppress output • A continuation line is shown with … • clc clears the command window • help foo displays the help for foo() • lookfor will search for a string in the help • ^C to abort a command

  15. More Commands • To save the current workspace to filename.mat: save filename • To load: load filename • To capture output: diary filename and diary off or diary on • To display a variable: disp var • To interact with the operating system: !

  16. Data Types • Originally just complex matrices • Now include • double • sparse (2-D only) • char • cell • struct • storage (specialized) • function handle • The fundamental types are multi-dimensional arrays

  17. Matrices and Arrays • A(i,j,k) accesses that entry in the matrix A • More next week

  18. Operators 1 • ! System command • ‘ Conjugate transpose, string delimiter • “ Quote • ( : ) Used in matrix subscripting • , Separates commands • … Continuation • / Right division • : Colon • ; Terminates a command without output

  19. Operators 2 • < Less than • <= Less than or equal • == Logical equal • > Greater than • >= Greater than or equal • @ Function handle • [..] Matrix building • [] Empty matrix • % Comment • & Logical and

  20. Operators 3 • \ Left division • ^ Power • | Logical or • >> Prompt • ~ Logical not • ~= Logical not equal • * Multiplication • + Addition • - Subtraction

  21. Array Operators • .’ Transpose • .* Array multiplication • ./ Array right division • .\ Array left division • .^ Array exponentiation • inv(A) Inverse

  22. IEEE Arithmetic • All arithmetic is in accordance with the double precision IEEE standard. • 64 bits per number • All computations are in floating point. • You can get NaNs if the computations are undefined.

  23. Statements • Multiple statements can appear on the same line, separated by semicolons or commas. • If a statement is terminated by a semicolon, output is suppressed; otherwise it is printed. • Output can be formatted with the format command

  24. Functions • MATLAB has thousands of functions, and you can add your own using m-files.

  25. Function Argument Lists • Input arguments are to the right of the function name, within parentheses • Output arguments are to the left of the function name, within square brackets • X = [3 4]; • norm(X) ans = 5 • norm(X,1) ans = 7 • [m,n] = size(A) m = 5 n = 3

  26. M-Files • Sample file %MARKS Exmark = [12 0 5 28 87 3 56]; Exsort = sort(Exmark) Exmean = mean(Exmark) Exmed = median(Exmark) Exstd = std(Exmark)

  27. Storage Allocation • Automatic, as necessary, and with garbage collection (notorious for memory leaks). • Array dimensions are expanded automatically as needed to make assignments sensible.

  28. Control System Toolbox • This is a toolbox for control system design and analysis. It supports transfer function and state-space forms (continuous/discrete time, frequency domain), as well as functions for step, impulse, and arbitrary input responses. Functions for Bode, Nyquist, Nichols plots, design with root-locus, pole-placement, and LQR optimal control are also included.

  29. Image Processing Toolbox • The Image Processing Toolbox builds on MATLAB's numeric, signal processing, and visualization capabilities to provide a comprehensive system for image processing and algorithm development. • Heavily used here.

  30. MMLE3 Identification Toolbox • The MMLE3 Identification Toolbox is a specialized toolbox for use with MATLAB and the Control System Toolbox for the estimation of continuous-time state-space models from observed input-output data.

  31. Model Predictive Control Toolbox • The Model Predictive Control Toolbox is especially useful for applications involving constraints on the manipulated and/or controlled variables. For unconstrained problems, model predictive control is closely related to linear quadratic optimal control, but includes modeling and tuning options that simplify the design procedure.

  32. Mu-Analysis and Synthesis Toolbox • The Mu-Analysis and Synthesis Toolbox contains specialized tools for the analysis and design of robust, linear control systems, extending MATLAB to provide additional application-specific capabilities.

  33. Nonlinear Control Design • This toolbox provides a Graphical User Interface to assist in time-domain-based control design. With this toolbox, you can tune parameters within a nonlinear SIMULINK model to meet time-domain performance requirements. You can view the progress of an optimization while it is running. Optimization routines have been taken from the Optimization Toolbox.

  34. Neural Network Toolbox • This is a toolbox for designing and simulating neural networks and supports implementation of the perceptron learning rule, the Widrow-Hoff rule, and several variations of the backpropagation rule. Transfer functions included are hard limit, linear, logistic, and hypertangent sigmoid. • This will be the toolbox you use most here.

  35. Optimization Toolbox • This is a toolbox for linear and nonlinear optimization. It supports unconstrained and constrained minimization, minimax, nonlinear least squares, multi-objective, semi-infinite optimization, linear programming, quadratic programming, and the solution of nonlinear equations.

  36. Robust Control Toolbox • This is a toolbox for robust control system design and supports LQG/loop transfer recovery, H2, H0, and mu- control synthesis, singular value frequency response, and model reduction.

  37. Signal Processing Toolbox • This is a toolbox for digital signal processing (time series analysis). It includes functions for the design and analysis of digital filters, like Butterworth, Elliptic, and Parks-McClellan, and for FFT analysis (power spectrum estimation). It also includes some two-dimensional signal processing capabilities. • Very popular in the acoustics field.

  38. Spline Toolbox • This is a toolbox for working with splines and is typically used for curve fitting, solution of function equations, and functional approximation.

  39. Statistics Toolbox • The Statistics Toolbox builds on the computational and graphics capabilities of MATLAB to provide: 1) statistical data analysis, modeling, and Monte Carlo simulation 2) building blocks for creating your own special-purpose statistical tools, and 3) GUI tools for exploring fundamental concepts in statistics and probability.

  40. Symbolic Math Toolbox • The Symbolic Math Toolbox contains functions for symbolic algebra, exact linear algebra, variable precision arithmetic, equation solving, and special mathematical functions. Its underlying computational engine is the kernel of Maple. The Extended Symbolic Math Toolbox augments the functionality to include Maple programming features and specialized libraries.

  41. System Identification Toolbox • This is a toolbox for parametric modeling. Identified models are in transfer function form (either z transform or Laplace transform) and state-space form (e.g., ARMA models or Box-Jenkins models).

  42. Chemometrics Toolbox • This toolbox contains a library of functions that allows you to analyze data based on chemometrics methods including multiple linear regression, classical least squares, inverse least squares, Q-matrix, factor based methods, principle component regression, and partial least squares in latent variables. There are also useful functions for plotting data.

  43. Frequency Domain System Identification Toolbox • This toolbox contains tools for accurate modeling of linear systems with or without delay. The models are transfer functions in s-domain or in z-domain. The procedures include excitation signal design, data preprocessing, parameter estimation, graphical presentation of results, and model validation (tests, uncertainty bounds, modelling errors).

  44. Hi-Spec™Toolbox • The Hi-Spec [tm ] Toolbox, a Partner Series Toolbox, was created by Jerry Mendel, C.L. (Max) Nikias, and Ananthram Swami. The Hi-Spec Toolbox is a collection of MATLAB routines whose primary features are functions for: • Higher-order spectrum estimation either by conventional or parametric approaches • Magnitude and phase retrieval • Adaptive linear prediction • Harmonic retrieval and quadratic phase coupling • Time-delay estimation and array signal processing

  45. Tutorial Exercises • Work through the brief tutorial if you have the text.

More Related