1 / 17

INTRODUCTION TO BASIC MATLAB

INTRODUCTION TO BASIC MATLAB. Introduction. MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming where problems and solutions are expressed in familiar mathematical notation. Typical uses include: Math and computation

kaz
Télécharger la présentation

INTRODUCTION TO BASIC 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 BASIC MATLAB

  2. Introduction • MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming where problems and solutions are expressed in familiar mathematical notation. • Typical uses include: • Math and computation • Algorithm development • Data acquisition • Modeling, simulation, and prototyping • Data analysis, exploration, and visualization • Scientific and engineering graphics • Application development, Including graphical user interface building

  3. Introduction (Cont’) • MATLAB is an interactive system whose basic data element is an array that does not require dimensioning. This allows you to solve many technical computing problems, especially those with matrix and vector formulations. • In university environments, it is the standard instructional tool for introductory and advanced courses in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-productivity research, development, and analysis.

  4. Introduction (Cont’) • MATLAB features a family of add-on application-specific solutions called toolboxes. • Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. • Areas in which toolboxes are available include signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many others.

  5. The MATLAB System • The MATLAB system consists of five main parts: • i) Development Environment • - This is the set of tools and facilities that help you use MATLAB functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and Command Window, a command history, an editor and debugger, and browsers for viewing help, the workspace, files, and the search path. • ii) The MATLAB Mathematical Function Library • - This is a vast collection of computational algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and Fast Fourier transforms.

  6. The MATLAB System (cont’) • iii) The MATLAB Language • - This is a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. It allows both "programming in the small to programming in the large" to create complete large and complex application programs. • iv) Graphics • - MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. It includes high-level functions for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. It also includes low-level functions that allow you to fully customize the appearance of graphics as well as to build complete graphical user interfaces on your MATLAB applications. • v) The MATLAB Application Program Interface (API) • - This is a library that allows you to write C and FORTRAN programs that interact with MATLAB. It includes facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading and writing MAT-files.

  7. Starting Matlab • When you start MATLAB, 4 windows appear (by default): • MATLAB Command Window • Current Directory Window • Workspace Window • Command History Window

  8. i) MATLAB Command Window: • To communicate with MATLAB program, use MATLAB command window. • MATLAB display the prompt (>> ) to indicate that it is ready to receive instructions.

  9. ii) Current Directory Window: • It is much like a file manager window. • Used to access files. • For example: file.m – it will open file in Matlab editor.

  10. iii) Workspace Window: • Display the variables created in the command window. • Workspace refers to the names and values of any variable in-use in the current work session.

  11. iv) Command History Window: • All the previous keystrokes entered in Matlab Command Window showed here. • You can click and drag the command into the Matlab command window or Matlab editor. • You can alter the appearance of the desktop by clicking ViewDesktop layout.

  12. Entering Commands and Expressions: • Try out this 3-line command in Matlab Command Window: • >> x=[0:002:8]; • >> y=5*sin(x); • >> plot(x,y): • When you put semicolon (;) at the end of your command line, Matlab will not shows the answer of your commands/expressions. • Example of mathematical expressions in Matlab prompt: • >> 8/10 • ans = 0.8000 • >> 5*anw • ans = 4

  13. Variables • A variable in Matlab is a symbol used to contain a value. • When we do not specify a variable name for a result, Matlab uses the symbol ans as a temporary variable containing the most recent answer. • Scalar variable: • >> r=8/10 • r = 0.8000 • >> s=5*r • s = 4

  14. Variables (Cont’) Scalar arithmetic operations:

  15. Variables (Cont’) • Variable names must begin with a letter and must contain less than 32 characters; contain letter, digits, and underscore. • Matlab is case-sensitive; the following names represent different variables: speed, Speed, SPEED. • Commands for managing the work session: • >> clc : clear the command window. • >> clear : removes all variables from memory. • >> clear var1,var2 : removes the variables var1 and var2. • >> quit : stops matlab • >> who : lists the variables currently in memory • >> whos :lists current variable and size. • : :generates an array having regularly spaced elements. • ; : suppresses screen printing, denotes a new row. • , :separates elements of an array.

  16. Computing with Matlab • Matlab has the ability to handle collection of numbers, called array. • Example of array variable: • >> x= [0 1 3 6]; % 4-sequence of array • >> u= [0 1; 2 1]; % 2x2 matrix • >> y= [0:0.01:2]; • >> length (y); % check total number of sequence-y • >> y(7); % check the value of y in array-7 • Polynomial roots: to find roots of >> a= [1, -7, 40, -34]; • >> roots (a) • Answer: roots of a: x=1, x=3+5i • Built-in and User Defined Functions.

  17. Computing with Matlab (cont’) Some commonly used mathematical function:

More Related