Docsity

MathWorks Documentation - MATLAB V7 Introductory and Programming, Notas de estudo de Engenharia Elétrica

Pré-visualização parcial do texto

Baixe MathWorks Documentation - MATLAB V7 Introductory and Programming e outras Notas de estudo em PDF para Engenharia Elétrica, somente na Docsity!

Getting Started with MATLAB

How to Contact The MathWorks

www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support

[email protected] Product enhancement suggestions [email protected] Bug reports [email protected] Documentation error reports [email protected] Order status, license renewals, passcodes [email protected] Sales, pricing, and general information

508-647-7000 (Phone)

508-647-7001 (Fax)

The MathWorks, Inc.

3 Apple Hill Drive

Natick, MA 01760-

For contact information about worldwide offices, see the MathWorks Web site.

Getting Started with MATLAB

© COPYRIGHT 1984–2007 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc.

Trademarks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, Embedded MATLAB, and PolySpace are trademarks of The MathWorks, Inc.

Other product or brand names are trademarks or registered trademarks of their respective holders.

Patents

The MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information.

Contents

Introduction

Matrices and Arrays

Programming

Data Analysis

External Interfaces

  • What Is MATLAB? 1-
    • Overview of MATLAB 1-
    • The MATLAB System 1-
  • MATLAB Documentation 1-
  • Starting and Quitting MATLAB 1-
    • Starting MATLAB 1-
    • Quitting MATLAB 1-
  • Matrices and Magic Squares 2-
    • About Matrices 2-
    • Entering Matrices 2-
    • sum, transpose, and diag 2-
    • Subscripts 2-
    • The Colon Operator 2-
    • The magic Function 2-
  • Expressions 2-
    • Variables 2-
    • Numbers 2-
    • Operators 2-
    • Functions 2-
    • Examples of Expressions 2-
  • Working with Matrices 2-
    • Generating Matrices 2-
    • The load Function 2-
    • M-Files 2-
    • Concatenation 2-
    • Deleting Rows and Columns 2-
  • More About Matrices and Arrays 2-
    • Linear Algebra 2-
    • Arrays 2-
    • Multivariate Data 2-
    • Scalar Expansion 2-
    • Logical Subscripting 2-
    • The find Function 2-
  • Controlling Command Window Input and Output 2-
    • The format Function 2-
    • Suppressing Output 2-
    • Entering Long Statements 2-
    • Command Line Editing 2-
  • Overview of MATLAB Plotting 3-
    • Plotting Process 3-
    • Graph Components 3-
    • Figure Tools 3-
    • Arranging Graphs Within a Figure 3-
    • Choosing a Type of Graph to Plot 3-
  • Editing Plots 3-
    • Plot Edit Mode 3-
    • Using Functions to Edit Graphs 3-
  • Some Ways to Use MATLAB Plotting Tools 3-
    • Plotting Two Variables with Plotting Tools 3-
    • Changing the Appearance of Lines and Markers 3-
    • Adding More Data to the Graph 3-
    • Changing the Type of Graph 3-
    • Modifying the Graph Data Source 3-
  • Preparing Graphs for Presentation 3-
    • Annotating Graphs for Presentation 3-
    • Printing the Graph 3-
    • Exporting the Graph 3-
  • Using Basic Plotting Functions 3-
    • Creating a Plot 3-
    • Plotting Multiple Data Sets in One Graph 3-
    • Specifying Line Styles and Colors 3-
    • Plotting Lines and Markers 3-
    • Graphing Imaginary and Complex Data 3-
    • Adding Plots to an Existing Graph 3-
    • Figure Windows 3-
    • Displaying Multiple Plots in One Figure 3-
    • Controlling the Axes 3-
    • Adding Axis Labels and Titles 3-
    • Saving Figures 3-
  • Creating Mesh and Surface Plots 3-
    • About Mesh and Surface Plots 3-
    • Visualizing Functions of Two Variables 3-
  • Plotting Image Data 3-
    • About Plotting Image Data 3-
    • Reading and Writing Images 3-
  • Printing Graphics 3-
    • Overview of Printing 3-
    • Printing from the File Menu 3-
    • Exporting the Figure to a Graphics File 3-
    • Using the Print Command 3-
  • Handle Graphics 3-
    • Using the Handle 3-
    • Graphics Objects 3-
    • Setting Object Properties 3-
    • Specifying the Axes or Figure 3-
    • Finding the Handles of Existing Objects 3-
  • Flow Control 4-
    • Conditional Control – if, else, switch 4-
    • Loop Control – for, while, continue, break 4-
    • Error Control – try, catch 4-
    • Program Termination – return 4-
  • Other Data Structures 4-
    • Multidimensional Arrays 4-
    • Cell Arrays 4-
    • Characters and Text 4-
    • Structures 4-
  • Scripts and Functions 4-
    • Overview 4-
    • Scripts 4-
    • Functions 4-
    • Types of Functions 4-
    • Global Variables 4-
    • Passing String Arguments to Functions 4-
    • The eval Function 4-
    • Function Handles 4-
    • Function Functions 4-
    • Vectorization 4-
    • Preallocation 4-
  • Introduction 5-
  • Preprocessing Data 5-
    • Overview 5-
    • Loading the Data 5-
    • Missing Data 5-
    • Outliers 5-
    • Smoothing and Filtering 5-
  • Summarizing Data 5-
    • Overview 5-
    • Measures of Location 5-
    • Measures of Scale 5-
    • Shape of a Distribution 5-
  • Visualizing Data 5-
    • Overview 5-
    • 2-D Scatter Plots 5-
    • 3-D Scatter Plots 5-
    • Scatter Plot Arrays 5-
  • Modeling Data 5-
    • Overview 5-
    • Polynomial Regression 5-
    • General Linear Regression 5-
  • What Is GUIDE? 6-
  • Laying Out a GUI 6-
    • Starting GUIDE 6-
    • The Layout Editor 6-
  • Programming a GUI 6-
  • Desktop Overview 7-
    • Introduction to the Desktop 7-
    • Arranging the Desktop 7-
    • Start Button 7-
  • Command Window and Command History 7-
    • Command Window 7-
    • Command History 7-
  • Help 7-
    • Help Browser 7-
    • Other Forms of Help 7-
    • Typographical Conventions 7-
  • Current Directory Browser and Search Path 7-
    • Running Files 7-
    • Current Directory 7-
    • Search Path 7-
  • Workspace Browser and Array Editor 7-
    • Workspace Browser 7-
    • Array Editor 7-
  • Editor/Debugger 7-
  • M-Lint Code Check and Profiler Reports 7-
    • M-Lint Code Check Report 7-
    • Profiler 7-
  • Other Development Environment Features 7-
  • Programming Interfaces 8-
    • Call MATLAB from C and Fortran Programs 8-
    • Call C and Fortran Programs from MATLAB 8-
    • Call Java from MATLAB 8-
    • Call Functions in Shared Libraries 8-
    • Import and Export Data 8-

Component Object Model Interface.................. 8-

Web Services...................................... 8-

Serial Port Interface............................... 8-

Index

xi

Introduction

What Is MATLAB? (p. 1-2) See how MATLAB ®^ can provide solutions for you in technical computing, what are some of the common applications of MATLAB, and what types of add-on application-specific solutions are available in MATLAB toolboxes. MATLAB Documentation (p. 1-5) Find out where to look for instruction on how to use each component of MATLAB, and where to find help when you need it. Starting and Quitting MATLAB (p. 1-7)

Start a new MATLAB session, use the desktop environment, and terminate the session.

1 Introduction

What Is MATLAB?

In this section... “Overview of MATLAB” on page 1- “The MATLAB System” on page 1-

Overview of MATLAB MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment 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

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 a fraction of the time it would take to write a program in a scalar noninteractive language such as C or Fortran.

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix computation.

MATLAB has evolved over a period of years with input from many users. In university environments, it is the standard instructional tool for introductory

1 Introduction

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.

MATLAB External Interfaces

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.

MATLAB Documentation

MATLAB Documentation

MATLAB provides extensive documentation, in both printable and HTML format, to help you learn about and use all of its features. If you are a new user, start with this Getting Started book. It covers all the primary MATLAB features at a high level, including many examples.

To view the online documentation, select MATLAB Help from the Help menu in MATLAB. Online help appears in the Help browser, providing task-oriented and reference information about MATLAB features. For more information about using the Help browser, including typographical conventions used in the documentation, see “Help” on page 7-8.

The MATLAB documentation is organized into these main topics:

- Desktop Tools and Development Environment — Startup and shutdown, the desktop, and other tools that help you use MATLAB - Mathematics — Mathematical operations - Data Analysis — Data analysis, including data fitting, Fourier analysis, and time-series tools - Programming — The MATLAB language and how to develop MATLAB applications - Graphics — Tools and techniques for plotting, graph annotation, printing, and programming with Handle Graphics ® - 3-D Visualization — Visualizing surface and volume data, transparency, and viewing and lighting techniques - Creating Graphical User Interfaces — GUI-building tools and how to write callback functions - External Interfaces — MEX-files, the MATLAB engine, and interfacing to Java, COM, and the serial port

Starting and Quitting MATLAB

Starting and Quitting MATLAB

In this section... “Starting MATLAB” on page 1- “Quitting MATLAB” on page 1-

Starting MATLAB On Windows platforms, start MATLAB by double-clicking the MATLAB shortcut icon on your Windows desktop.

On UNIX platforms, start MATLAB by typing matlab at the operating system prompt.

You can customize MATLAB startup. For example, you can change the directory in which MATLAB starts or automatically execute MATLAB statements in a script file named startup.m.

For More Information See “Starting MATLAB on Windows Platforms” and “Starting MATLAB on UNIX Platforms” in the Desktop Tools and Development Environment documentation.

MATLAB Desktop

When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB.

The following illustration shows the default desktop. You can customize the arrangement of tools and documents to suit your needs. For more information about the desktop tools, see Chapter 7, “Desktop Tools and Development Environment”.

1 Introduction

Quitting MATLAB To end your MATLAB session, select File > Exit MATLAB in the desktop, or type quit in the Command Window. You can run a script file named