MATLAB® the Language of Technical Computing
Total Page:16
File Type:pdf, Size:1020Kb
MATLAB® The Language of Technical Computing Function Reference Volume 2: F - O Version 7 How to Contact The MathWorks: www.mathworks.com Web comp.soft-sys.matlab Newsgroup [email protected] 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. Mail 3 Apple Hill Drive Natick, MA 01760-2098 For contact information about worldwide offices, see the MathWorks Web site. MATLAB Function Reference Volume 2: F - O COPYRIGHT 1984 - 2004 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 repro- duced 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. MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and TargetBox is a trademark of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders. Printing History: December 1996 First printing For MATLAB 5.0 (Release 8) June 1997 Online only Revised for MATLAB 5.1 (Release 9) October 1997 Online only Revised for MATLAB 5.2 (Release 10) January 1999 Online only Revised for MATLAB 5.3 (Release 11 June 1999 Second printing For MATLAB 5.3 (Release 11) June 2001 Online only Revised for MATLAB 6.1 (Release 12.1) July 2002 Online only Revised for 6.5 (Release 13) June 2004 Online only Revised for 7.0 (Release 14) Contents Functions — Categorical List 1 Desktop Tools and Development Environment . 1-2 Startup and Shutdown . 1-2 Command Window and History . 1-3 Help for Using MATLAB . 1-3 Workspace, Search Path, and File Operations . 1-3 Programming Tools . 1-5 System . 1-6 Mathematics . 1-7 Arrays and Matrices . 1-8 Linear Algebra . 1-10 Elementary Math . 1-12 Data Analysis and Fourier Transforms . 1-15 Polynomials . 1-16 Interpolation and Computational Geometry . 1-17 Coordinate System Conversion . 1-18 Nonlinear Numerical Methods . 1-18 Specialized Math . 1-20 Sparse Matrices . 1-20 Math Constants . 1-22 Programming and Data Types . 1-23 Data Types . 1-23 Arrays . 1-28 Operators and Operations . 1-30 Programming in MATLAB . 1-33 File I/O . 1-38 Filename Construction . 1-38 Opening, Loading, Saving Files . 1-39 Low-Level File I/O . 1-39 Text Files . 1-39 XML Documents . 1-39 Spreadsheets . 1-40 i Scientific Data . 1-40 Audio and Audio/Video . 1-41 Images . 1-41 Internet Exchange . 1-42 Graphics . 1-43 Basic Plots and Graphs . 1-43 Annotating Plots . 1-44 Specialized Plotting . 1-44 Bit-Mapped Images . 1-47 Printing . 1-47 Handle Graphics . 1-47 3-D Visualization . 1-50 Surface and Mesh Plots . 1-50 View Control . 1-51 Lighting . 1-53 Transparency . 1-53 Volume Visualization . 1-53 Creating Graphical User Interfaces . 1-54 Predefined Dialog Boxes . 1-54 Deploying User Interfaces . 1-55 Developing User Interfaces . 1-55 User Interface Objects . 1-55 Finding Objects from Callbacks . 1-55 Functions — Alphabetical List 2 ii Contents 1 Functions — Categorical List The MATLAB® Function Reference contains descriptions of all MATLAB commands and functions. Select a category from the following table to see a list of related functions. Desktop Tools and Startup, Command Window, help, editing and Development Environment debugging, tuning, other general functions Mathematics Arrays and matrices, linear algebra, data analysis, other areas of mathematics Programming and Data Function/expression evaluation, program Types control, function handles, object oriented programming, error handling, operators, data types, dates and times, timers File I/O General and low-level file I/O, plus specific file formats, like audio, spreadsheet, HDF, images Graphics Line plots, annotating graphs, specialized plots, images, printing, Handle Graphics® 3-D Visualization Surface and mesh plots, view control, lighting and transparency, volume visualization. Creating Graphical User GUIDE, programming graphical user Interface interfaces. External Interfaces Java, COM, Serial Port functions. See Simulink®, Stateflow®, Real-Time Workshop®, and the individual toolboxes for lists of their functions 1 Functions — Categorical List Desktop Tools and Development Environment General functions for working in MATLAB, including functions for startup, Command Window, help, and editing and debugging. “Startup and Shutdown” Startup and shutdown options “Command Window and Controlling Command Window and History History” “Help for Using Finding information MATLAB” “Workspace, Search File, search path, variable management Path, and File Operations” “Programming Tools” Editing and debugging, source control, Notebook “System” Identifying current computer, license, product version, and more Startup and Shutdown exit Terminate MATLAB (same as quit) finish MATLAB termination M-file genpath Generate a path string matlab Start MATLAB (UNIX systems) matlab Start MATLAB (Windows systems) matlabrc MATLAB startup M-file for single user systems or administrators prefdir Return directory containing preferences, history, and layout files preferences Display Preferences dialog box for MATLAB and related products quit Terminate MATLAB startup MATLAB startup M-file for user-defined options 1-2 Desktop Tools and Development Environment Command Window and History clc Clear Command Window commandhistoryOpen the Command History, or select it if already open commandwindow Open the Command Window, or select it if already open diary Save session to file dos Execute DOS command and return result format Control display format for output home Move cursor to upper left corner of Command Window matlab: Run specified function via hyperlink (matlabcolon) more Control paged output for Command Window perl Call Perl script using appropriate operating system executable system Execute operating system command and return result unix Execute UNIX command and return result Help for Using MATLAB doc Display online documentation in MATLAB Help browser demo Access product demos via Help browser docopt Web browser for UNIX platforms docsearch Open Help browser Search pane and run search for specified term help Display help for MATLAB functions in Command Window helpbrowser Display Help browser for access to full online documentation and demos helpwin Provide access to and display M-file help for all functions info Display Release Notes for MathWorks products lookfor Search for specified keyword in all help entries playshow Run published M-file demo support Open MathWorks Technical Support Web page web Open Web site or file in Web browser or Help browser whatsnew Display Release Notes for MathWorks products Workspace, Search Path, and File Operations • “Workspace” • “Search Path” • “File Operations” 1-3 1 Functions — Categorical List Workspace assignin Assign value to workspace variable clear Remove items from workspace, freeing up system memory evalin Execute string containing MATLAB expression in a workspace exist Check if variables or functions are defined openvar Open workspace variable in Array Editor for graphical editing pack Consolidate workspace memory uiimport Open Import Wizard, the graphical user interface to import data which Locate functions and files who, whos List variables in the workspace workspace Display Workspace browser, a tool for managing the workspace Search Path addpath Add directories to MATLAB search path genpath Generate path string partialpath Partial pathname path View or change the MATLAB directory search path path2rc Replaced by savepath pathdef List of directories in the MATLAB search path pathsep Return path separator for current platform pathtool Open Set Path dialog box to view and change MATLAB path restoredefaultpathRestore the default search path rmpath Remove directories from MATLAB search path savepath Save current MATLAB search path to pathdef.m file File Operations cd Change working directory copyfile Copy file or directory delete Delete files or graphics objects dir Display directory listing exist Check if variables or functions are defined fileattrib Set or get attributes of file or directory filebrowser Display Current Directory browser, a tool for viewing files lookfor Search for specified keyword in all help entries