Getting started with MATLAB by rudra pratap (2009)

287 11 0
Getting started with MATLAB by rudra pratap (2009)

Đ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

Getting Started with www.elsolucionario.net MATLAB www.elsolucionario.net Updated for Version 7.8 (Release 2009a} www.elsolucionario.net Under author no Disclaimer circumstances assume liability thereof, any does responsibility the and for an)' injury caused to the reader by toxic fumes and explosions resulting from mixing incompatible matrices and vectors Array operations are known to cause irritability and minor itching to beginners The author, however might buy the reader a cup of coffee in the case of serious distress In rare cases of very flattering comments or very creative suggestions about improving this book, the author might even buy the reader lunch The reader is encouraged to try his/her luck by sending comments to pratap@mecheng.iisc.emet.in or www.elsolucionario.net pratap.mems@gmail.com Getting Started with www.elsolucionario.net MATLAB RUDRA PRATAP Department of Mechanical Engineering Indian Institute of Science, Bangalore New York · Oxford OXFORD UNIVERSITY PRESS 2010 www.elsolucionario.net A Quick Introduction for Scientists and Engineers www.elsolucionario.net Oxford University Press, Inc., publishes works that further Oxford University's objective of excellence in research, scholarship, and education Oxford Auckland Dar es NewYork Bangkok Buenos Aires Cape Town Istanbul Chennai Karachi Ko\kata Kuala Lumpur Madrid Melbourne Mexico City Mumbai Nairobi Sao Paulo Shanghai Taipei Tokyo Toronto Salaam Delhi Hong Kong Copyright© 2010 by Oxford University Press, Inc Published by Oxford University Press, Inc 198 Madison Avenue, New York, New York, 10016 Oxford is a registered trademark of Oxford University Press ® MATLAB is a registered trademark of The MathWorks ® Handle Graphics is a registered trademark of The MathWorks All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior permission of Oxford University Press Library of Congress Cataloging-in-Publication Data Pratap, Rudra, 1964- Getting started with MATLAB: a quick introduction for scientists and engineers / Rudra Pratap p em ISBN: 978-0-19-973124-4 MATLAB Science-Data processing Engineering mathematics-Data processing I Title Q183.9.P734 2010 620.001'51 dc22 Printed in the United States of America 10 200 902 033 www.elsolucionario.net http://www.oup-usa.org www.elsolucionario.net To Ma Gayatri www.elsolucionario.net and my parents Shri Chandrama Singh and Smt Bachcha Singh www.elsolucionario.net www.elsolucionario.net www.elsolucionario.net xii Preface Introduction What Is MATLAB? Does MATLAB D o Symbolic Calculations? Will MATLAB Run on My Computer? Where Do I Get MATLAB? 1.5 How Do I Use This Book? 1.6 Basics of MATLAB MATLA B windows 1.6.2 On-line help 1.6.3 Input-output 6.4 File types Platform dependence 6.6 General commands you should remember 1.7 Visit This Ag ain 3 4 5 7 10 10 12 13 15 Tutorial Lessons The Basics Lesson : A Minimum MATLAB Session 2.2 Lesson 2: Cre at ing and Wo rking with Arrays of Numbers 2.3 Lesson 3: Creating and Printing Simple Plots 2.4 Lesson 4: Creating, Saving, and Executing a Script File 2.5 Lesson 5: Creating and Executing a Function File Directional Explorations 2.6 Lei:ii:iUH 6: WuLking with Arrays and Matrices Lesson 7: Working with Anonymous Functions 2.8 Lesson 8: Symbolic Computation Lesson 9: Importing and Exporting Data 2.10 Lesson 10: Working with Files and Directories 2.11 Lesson 11: Publishing Report s 16 17 21 25 29 33 38 39 43 47 51 55 58 www.elsolucionario.net Contents www.elsolucionario.net Interactive Computation 3.1 3.2 3.3 3.4 3.5 3.6 3.7 Matrices and Vectors 3.1.1 Input 3.1.2 Indexing (or subscripting ) 3.1.3 Matrix manipulation Creating vectors 3.1.4 Matrix and Array Operations Arithmetic operations 3.2.2 Relational operations 3.2.3 Logical operations 3.2.4 Elementary math funct i ons 3.2 Matrix functions Character strings 3.3 Manipulating character strings 3.3.2 The eval function A Special Note on Array Operations 3.4 Vectorization Command- Line Functions Inline functions Anonymous functions Using Built-in Functions and On-line Help 3.6.1 Example 1: Finding the determinant of a matrix 3.6.2 Example 2: Finding eigenvalues and eigenvectors Saving and Loading Data 3.7.1 Saving into and loading from the binary Mat-files 3.7.2 Importing data files 3.7.3 Recording a session with diary Plotting Simple Graphs Programming in MATLAB: Scripts and Functions Script Files 4.2 Function Files Executing a function 4.2.2 More on functions 4.2 M-Lint code analyzer 4.2.4 Subfunctions Nested functions: 4.2.6 Compiled ( parsed ) functions : The p-code 4.2.7 The profiler 4.3 Language-specific Features 4.3.1 Use of comments to create on-line help 4.3.2 Continuation 4.3.3 Global variables 4.3.4 Loops, branches, and control-flow Contents 63 65 65 66 66 72 73 73 74 74 75 77 77 79 80 81 82 83 83 83 85 87 87 90 90 91 91 92 99 99 102 03 10 108 09 10 110 111 11 11 1 12 112 14 www.elsolucionario.net viii www.elsolucionario.net 4.3.5 Interactive input 4.3.6 Recursion Input / output 4.4 Advanced Data Objects 4.4 Multidimensional matrices 4.4.2 Structure s 4.4.3 Cells 4.5 Publishing Reports ix 117 119 119 121 121 122 125 129 Applications Linear Algebra Solving a linear system 1.2 Gaus sian elimination 1.3 Finding eigenvalues and eigenvectors Matrix factorizations Advanced topics Curve Fitting and Interpolation Polynomial curve fitting o n the fly 5.2.2 Do it yourself: Curve fitting with polynomial functions Least squares curve fitting 5.2.4 General nonlinear fits Interpolation 5.3 Data Analysis and Stat ist ics 5.4 Numerical Integration ( Quadrature) 5.4 Double integration 5.5 Ordinary Di fferential Equations Example 1: A first-order linear ODE 5.5.2 Example 2: A second-order nonlinear ODE ode23 versus ode45 5.5.4 Specifying tolerance The ODE suite 5.5 Event location Nonlinear Algebraic Equations 5.6.1 Roots of polynomials Advanced Topics 135 175 Graphics Basic 2-D Plots 6.1.1 Style options Labels, title, legend, and other text objects 6.1.3 Axis control, zoom in, and zoom out Modifying plots with the plot editor Overlay plots Speciali zed 2-D plots 6.2 Using subplot for Multiple Graphs 135 135 136 137 138 139 139 139 141 144 147 147 150 152 154 156 157 158 160 162 163 165 68 170 171 175 176 76 177 178 179 183 189 www.elsolucionario.net Contents 258 ; Fgr .ort,#ne he.lp type: help strfuri www.elsolucionario.net The MATLAB Language Reference A.9 Character String Funct ions See Section 3.3 General String Functions abs string char strcmp ev al setstr lower str cat i s s tr upper strvcat i s char int2str str2num For on-line help A.lO help graphi cs See Chapter type : help graph2d num2str s s c anf sprintf hex2de c dec2hex hex2num mat str dec2bin Graphics Functions help graph3d EZ Graphics ezplot ezplot3 ezpolar ezme sh e z c ont our ezmeshc e z c ont ourf ezgraph3 ezsurf ezsurf c 2-D Graphics plot loglog semilogx semi logy bar error bar c ompas s f e ather polar fill hist rose fplot stairs qu i v e r 3-D Graphics plot3 surf f ill3 surf c mesh s urf l me she cyl inder meshz sphere Contour Plots c ontour c ont our3 c ont our c clabel p c o l or Volumetric Plots slice coneplot i s o surf ac e streamline i s o c ap s streamtube i s o c o l or s streamli c e c o t our s l i c e streampart i c l e s Graphics Annotation xlabel t ext ylabel gtext zlabel grid t itle plotedit legend rectangle www.elsolucionario.net String {==} Number Conversion A.lO Graphics Functions www.elsolucionario.net 259 Axis Control and Graph Appearance colormap axi s shading hidden view Window Creation and C ontrol elf close f igure gcf subplot axe s axi s caxis cla www.elsolucionario.net Axis Creation and Control gca Handle Graphics Objects and Operations axe s f igure l ine image pat ch uicontrol surf ace uimenu t ext delete drawnow g et reset set comet Animation and Movies getf rame movie moviein avi f i l e movie2avi frame2im rotat e3D im2frame rotate Hard Copy and Miscellaneous pr int ori ent print opt gin put hold Color Control and Lighting c ax i s bone cool surf l c o l o rmap c opper hot specular f l ag gray shading rgbplot hBv2rgb hsv brighten rgb2h:sv pink diffuse helP c.olor www.elsolucionario.net The 260 For on-line help type: MATLAB L anguage Re ference A l l Some Applications Functions A.ll.l D at a analysis and Fourier transforms help dat afun Basic Statistics Commands median cumprod mean prod std sum cum sum max sort Correlation and Finite Difference cov del2 diff gradient Fourier Transforms fft abs fft2 angle conv conv2 f f t shift cplxpair ifft nextpow2 ifft2 unwrap Filtering and Convolution For on-line type: help A 11.2 dconv f i lter f ilter2 Polynomials and dat a interpolat ion help polyfun Polynomials polyder po l y deconv c onv po lyf it residue polyval po l yva l m root s Data Interpolation int erp1 interp2 interpft interpn griddata Fourier Transforms fft abs fft2 angle f f t shift cplxpair ifft nextpow2 ifft2 unwrap Filtering and Convolution conv For on-line help type : A 1 conv2 dconv f i lter f i lt er2 Nonlinear numerical methods help funfun Functions fmin quad ode23 fmins quadl ode45 fminbnd dblquad ode 13 fminsearch bvp4c ode23t fzero pdepe ode23s trapz dde23 ode f i l e www.elsolucionario.net corrcoef www.elsolucionario.net B ibliography [1] MA TLAIJ® 'l Desktop Tools and Development Environment, The MathWorks, Inc , 2004 [2) MA TLA EJ® Mathematics, T h e MathWorks , Inc , 2009 MA TLAJ3® Programming Fundamentals, T h e MathWorks , Inc , 2009 MA TLAIJ® External Interfaces, The Math Works, Inc , 2009 [5] Creating Graphical User Interfaces, The Math Works, Inc , 2009 [6] Using MA TLAJ3® 'l Graphics, The MathWorks, Inc , 2009 [7] MATLAB® Release Notes, The MathWorks, Inc , 2009 [8] Kernighan, B W , and D M Ritchie, The C Programming Language, second [3] edition, Prentice Hall Inc , 1993 [9] Strang, G., Linear Algebra and Its Applications, third edition, Saunders HBJ College Publishers, 1988 [ 0] Golub, G H., and C F Van Loan, Matrix Computations, third edition, The Johns Hopkins University Press , 997 [1 1] Horn, R A , and C R J ohnson , Matrix Analysis, Cambridge University Press, 1985 [12] Gerald, C F., and P Wheatley, Applied Numerical Analysis, fifth edition, 1994 [13 ] Press W , B Flannery, S Teudolsky, and W Vetterling, Numerical Recipes Addison Wesley Publishing Company, in C: The Art of Scientific Computing, second edition, Cambridge University Press, 1992 www.elsolucionario.net [4] www.elsolucionario.net www.elsolucionario.net ! , 7, 252 \ , 73 ' ( right quote ) , 251 ' ' ( single quotes ) , 252 ( ) ' 252 " 251 ' 252 ' 252 /, 73 : , 251 ; , 251 », , 63 ©, 43 , 83 [ J ' 252 0 0 array operator, 22 arrays, 39 creating, tutorial on, 39 ASCII files loading, 90 reading and writing, 90 augmented matrix, 136 axe s , 205, 206, multiple, 212 placing, 2 sizing, 2 axes , 212 axi s , 25, 26, 77 % , 64, 103, 252 %%, 58, 129 , 252 bar, 185 2-D plots, 25 bar3h, 189 barh, 186 Basic Fitt i ng, 139 { } , 252 bar3 , 189 abs , 76, 79 Adams-Bashforth-Moulton methods, 163 beats, 73 alpha value, 216 bench, 12 angl e , 76 binary data, 52 animating graphs, 244 boundary value problem, 171 animation, 2 branching, 14 anonymous functions , 83, with if-elseif-else, 114 defining, 43 with switch-cas e , 15 evaluating, 44 break, 1 handle of, 43 bvp4c , tutorial on , 43 case sensitivity, using , 44 an s , , 04 applications , 135-171 ar e a , 186 arithmetic mean, 51 arithmetic operations, on element-by-element basis, 73 on matrices, 73 array operation, , , 73 cd, , 00 c e i l , 77 cell, 53, 125 containers, 126 content indexing, 126 contents, 126 c e l l , 126 cell script , 129, 252 www.elsolucionario.net www.elsolucionario.net Index www.elsolucionario.net cell2mat , c e l l d i sp , compounded interest, 35 53 128 c omput er , 12 c e l lpl ot , 128 cells, 121 creating, 126 manipulating, 128 char, 53, 79 character strings, 77 evaluat e , 80 manipulating, 79 manip ul ation functions, 79 quote within, 79 spaces in, 77 characters, 77 Cholesky factorization, 138 circ le , 23, 25, 30 clc, 12 clear, , 52 clearing command window, figure window, 12 workspace function, workspace variab les , elf , 12 clock, 12 code analyzer, 108 colon, 251 color EPS , colors, column vector, 2 comet , 8 , 221 comet , 189 comma, 251 command history, command length li mit , 63 command prompt , command wind ow , 63 commands long, 63 maximum length of, 63 , where Index to type, 63 comment lines, 29, 103 comments, 64, 1 c ompas s , 187 compiled function, 10 complex, 76 complex functions , 76 complex numbers, 19 computer algebra, 235 conditional c:alcula.t.ions , s ee control-flow conj , 76 continuation, , 1 , 252 c ontour , 8 contour3, 189, 196 control-flow, 1 c opyf i l e , , 56 cro s s , 35 cross product , 35 cubic s p line s , 148 cumprod, cumsum, cumulative product , cumulative sum, 151 current directory, 55 curve fit cubic, 141 double exponential, 147 least squares, 144 linear, 140, 143 , 172 nonlinear , 147, 72 nonpolynomial, 144 norm of the residuals, 140 polynomial, 139 power laws, 144 quadratic, 141 residuals, 140, 141 curve fitting, 139 cyl inder , 190, 200 DAEs, 163, 171 data exporting tutorial, importing tutorial, loading, saving, data analysi s , 150 data object:s, 121 cells, , 25 multi d imension al matrices, structures, , 122 Data Stat istics, 150 data statistics, 73 d at a type, , dat e , 12 www.elsolucionario.net 264 www.elsolucionario.net dblquad, 154 dde23, 171 debugging commands, 254 delay differential equations, 171 demo, demo , 7, 12 det , 87 determinant , 87 diag, 70, 71 d i ary , dif f ' , 152, 238 differential algebraic equations, 163 dimension, 66 dir, 12, 56 directories, 5 , 56 directory, 1 directory information commands, directory navigation, 38 display format , 63 division left , 73 , 136 right , 73 c , 253 double integration, 54 nonrectangular domains, 155 drawnow, 222 · undefined command, 232 eval , 79 , 80 event location, 165 event location in ODEs, 165 exi st , 132 exit , 12 exp, , 76 expand, 48 expm, 77 exponential, exponential functions, 76 exporting data, 38 eye , 42, , 71 ezcontour, 94, 183 ezcont ourf , 95 ezmesh, 96, 189 ezmeshc , 96 ezplot , 93, 183, 236 ezplot3, 94, 189 ezpolar, 94, 183 ezsurf , 95, 189 ezsurf c , 96 face alpha value, transparency, f actor, 48 edge factorial, 35 alpha value, factorization, 48 transparency, 216 fancy plots, 27 ed i tpath, fclose, 119 f eval, , e i g , 8 , 89, 138 eigenvalues and eigenvectors, 87, 137 Fibonacci sequence, 1 computing a few, 139 Fig-files, 10 file I/0 , 254 eigs , 139 elementary matrices, s e e utility matrices file types, 10 Fig-files, 10 e l l i p s o id, 190, 200 · emacs editor, Encapsulated PostScript , EPS , erasemo d e , 223 err o r , 116 error function, 53 errorbar , 185 errors, 229 dimension mismatch , 229 misformed expression, 230 misused parenthesis/brackets, 232 M-files , 10 Mat-files, 10 Mex-files, 10 P - filcs, 10 files, 55 f il l , 185 f ill3, , 96 f itdemo , 147, 73 f ix , 77 f l ipud, 72, floating-point numbers, 265 www.elsolucionario.net Index www.elsolucionario.net catalog of, 96-200 f l o o r , 77 f mi nbnd , 171 fminsearch, , f open, 1 f or l oo p , 1 1 , 73 f ormat , , 7, , 64 fplot , Index 92, 184 fprint f , 1 surface, 194 v i ew an gle , 190 wire-frame, 94 anim at ion , 221 axiR rnntro] , 77 se mi , 78 211 Handle Graphics, 205 hard copy, l ab e ls , 176 l eg end , 77 line options, 76 deleting obj ect s , function definition line , 103 evaluat i n g , evaluating w ith function handle , evaluating with f eval , mesh plots, executing, object hierarchy, 205 in the input list , 106 children , 205 input list , parent , 205 inside another function, , 09 object properties, 207 lowerc as e f in fun c t i o n , 102 placement , 212 nested, no printing, output l i st , 10 rotate view, 192 performance, l 1 saving profile, l 1 as F i g- fi le, 220 function file, , , 1 , as M-code, 2 anatomy of, to reusable files , 220 c omme nt s in, specialized 2-D p lot s , 183 c re at ing, 33 surface plots, 193 example of, 04 text in, 76 executing, 33 tit le , 76 subfunctions i n, v i ew command, function h and le , , 83 , , 252 graphics functions , 258 functions graphics layout , anonymous , 43 graphics objects funt o o l , 237 getting p r operties of, 207 f z e r o , , 68-1 70 setting prop ert i es of, 207 Gaussian elimination, graphs, 139 general commands, 12 griddat a, general information commands, gtext , , general-purpose commands, 253 H1 line, 31 ge o met ri c series, 23 , 35 h an d le, 205 get , 208 Handle Graphics, 20 5, 2 global, 1 global variables, 1 object han d le s , 206 h and le of an obj ect, 205 gradient , 188 hard copy, graphics, 175-227 help, 7, , 253 2-D p l ots , 175 catalog of, 3-D 184-188 plots, 189 help facility, 89 help window, 90 www.elsolucionario.net 266 helpde sk, 7, , 85, 90, 253 helpwin, 7, 12, 85 Hermite interpolant , 147 hgsave , 220 hist , 187 hold, 79 hom e , HTML , 58, 131 ident ity matrix, 70 if-elseif -e l s e , 105, 1 , 14 imag, 76 imaginary number i , 19 implicit ODEs, 171 import wizard, 91 importdata, 91 importing audio data, 91 data files, 91 image data, m ovie data, 91 spreadsheet data, importing data, 38 index vector , inl i n e , 83 inline function, 83, 106, 132 examples of, 84 inner product , , 73, 231 input , 1 input/output , 1 , 254 integration double, 154 numerical, 152 trapezoidal rule, 152 interactive computation, 63-96 interactive input , 1 input , 1 keyboard, 1 menu, 1 pause, 1 interpolation, , 147 1-D (interp l ) , 148 2-D ( interp2) , 148 3-D (interp3) , 148 FFT-based ( interpft ) , 148 Hermit e , 14 schemes, 149 spline, 147 www.elsolucionario.net 267 spl ine , 148 surface, 203 i s empty, 105 keyboard, 1 labels, 176 language constructs, 254 LaTeX, 129 LaTeX commands, 130 least squares curve fit , 4 left d ivisio n , 136 legend, 176 legend, 77, Ul2 length, length of a curve, 73 line changing data points, 209 changing line style, 209 changing line thickness, 209 l ine, , 209 linear algebra, 135 eigenvalues and eigenvectors, 137 solving a linear system, 135 linear system, l insolve, 136 l inspace, 72 load, 10, 52, 90 loading multiple files, 97 loading data, 38, , 90 local operating system acces si ng , log, 19, 76 log scale plots, 27 log10, 19, 76 log2, 76 logarithm, 19, 76 logical, 68 logical functions, 75 logical operations, 71 loglog, 27, 84 logm, 77 l ogspace, 72 lookfor, 7, , , 85, 103, 1 , 253 error in using, 90 loops, 14 for, 1 , 14 www.elsolucionario.net Index Index www.elsolucionario.net exponential ( expm) , exp on enti ati on , 41 factorizations, 138 flip, 72 functions, 77 whi l e , 1 , 14 l s , 12 , 56 LU factorization, 138 M-book, 131 M-files, 7, , !) !) M-Lint , 108 Maple, margin help box, M at - file , , , 52, 90 math functions, 75 Mathematica, MathWorks, Inc address, identity, 70 MATLAB data type, launching, 1 main features of, operating systems, programming in, 99 prompt , , 63 toolboxes, users , what 1s 1t , MATLAB l angu age , 1 �-131 MATLAB notebook, 131 MATLAB publis he r , 38 MATLAB windows , 5 l dimensions, 6 elements , 40 , b !oi upper triangular, 72, 97 ut i li ty, 70 zero, 69, 70 matrix equation, 136 matrix operations, 73 matrix square root , e di to r, figure, graphics, matrices, 39 tutorial on, 39 matrix, 65 accessing elements ff, 66 appending a column to, 69 ap p en di ng a row to , 69 column i ndex, 66 decomposition, see lractorizaLions deleteing a c o l umn , 40 de let eing a row, 40 delet ing a column, 70 deleting a row, 70 determinant, index specifier ( : ) , 40 indexing, 66 indexing with logicals, 68 i n d ice s , 40 initialization, 69 input , 40, 65, 67 continuation in, logarithm (logm) , 77 lower triangular, 72 m ani p ul at i on , 40, 66, 67 multidimensional, null, 65, reshaping, row index, 66 s i ngle column, 68 special, 72 symmetric , 97 transpose , who makes, command, 77 max, mean, median, 151 menu, 118 mesh, 189, 193, 198 meshc , 189 meshgrid, meshz , 189, 198 Mex- files, 10 min, minimum, mkdir, 12, 56 mlock, 12 77 mod, 7 mo difyi ng plots, 210 with object handles, 21 plotedit , 78 PropEdit, 1 www.elsolucionario.net 268 www.elsolucionario.net more , 9, 12, 27, 64 movie , 221 movies, 221 MS Excel file, 53 MS Word, 58 multiple graphs, 189 munlock, 12 MuPAD animation, 244 Notebook, 243, 245 plotfunc2d, 247 plotfunc3d, 247 Symbolic Math Toolbox, 235 mupad, 243 names of variables, 63 nargin, 104, 132 nargout , 104, 132 nested functions, 10 nonlinear algebraic equations, 168-171 notebook, 131 nth root , 76 nthroot , 76 null matrix, 69 num2str, 79 object handles, 206 getting, 206 ODE suite, 163 event location in, 165 solver options, 164 ode23, 108, 157 ode45 , 108, 157 ode i c , 171 on-line help, built-in functions, 85 categories, 85 creating, 1 help, lookfor, , 85 menu bar, 90 on-line help commands, one s , , , open, operations arithmetic, 73 logical, 74 relational, 74 269 operators, 255 ordinary differential equations, 156 outer product, , 73, 231 overlay plots, 27, 79 with hold, 79 with l ine , 181 with plot , 179 p-code, 10, 1 P-files, 10 paged output; · parsed function, 110 partial differential equations, 171 patch, 216 path, 11, 12, 55 pause, 118 pcode , 10 pcolor, 188 pdepe , 171 p i e , 186 pie3, 189, 199 plot , 25, 26, 92, 175, 79, 180 plot editor, 78 plot3, 189, 190, 196 plotedit , 78 plotting simple graphs, 92 plotting vector fields, 201 plotting volumetric data, 202 plotyy, 186 polar, 185 polyf i t , 142 polyval , 142 PostScript, 219 precision o f computation, 63 pretty, 49, 241 print , 64 print , 25, 26, 219 printing, 11 prod, 35, prof i l e , 1 profiler, 1 projectile, 165 propedit , 78 properties of a line, 207 property editor, 78 pseudocode, 108 publish, 131 publish, 59, 131 www.elsolucionario.net Index www.elsolucionario.net publish configuration edit , 131 figure size control, 131 publisher, 129 publishing, 252 mathematical equations, 129 publishing reports, 8, 129 punctuation marks, 251 pwd, , 56 QR factorization, 138 quad, 152 quadl , 152 quadrature, 152 qui t , 12, 17, 18 quitting MATLAB , 12 quiver, 88 , 201 quiver3, 189 rand, 70 reading a file , 1 real, 49, 76 recall commands, recording a session, recursion , 1 , 3 91 relational operations, 74 relative tolerance, 162 rem, 77 report figure size in, 131 reshape, 68 residual, 140 resonance, 73 return, 1 RGB values, 218 ribbon, 9 right division, 73 root nth, 76 square, 76 root s , 70 roots of polynomials, 170 rotate view in 3-D , 192 rotate3d, 92 ro un d , 77 round-off funct i ons , 77 row and column indices, 66 row reduced echelon form, 137 Index row vector, 22 Runge-Kutta method, 156, 163 s ave , 10, 52, 90 saving multiple files, 97 saving data, 38, 51, 90 saving graphs, 219 s c atter3, 189 screen output , , 64 floating point format, page control with more, 12 script file, 10, 16, , 53, 99 creating, 29 executing, 29 name of, 101 saving, 29 semicolon, 251 semilogx, 27, 184 s emilogy, 27, 184 set , 208 s ign, 77 simple graphics with e z c ont o u r , 94 ezcont ourf , 95 ezplot , 93 ezplot3 , 94 ezpolar, 94 ezsurf , 95 ezsurf c , 96 fplot , 92 simple graphs, 16 s imp l i f y , 49, 241 singular value decomposition, 138 size, , 66 slash, 136 s l i c e , 189, 200 solution of ODEs, 156 of order one, 157 of order two, 58 solve , 49 , 238, 240 sort , 151 space curve, 27 sparse matrices, 39, 25 special matrices, 72 special variables and constants, sphere , 190, 200 spline, 147 254 www.elsolucionario.net 270 www.elsolucionario.net spy, 97 sqrt , 76 sqrtm, 77 square root , 76 stairs , 187 standard deviation, 151 statistics, 150 stem, 187 stem3, 189, 199 stiff equations, 156 stiff solvers, 163 strcmp, 79 strings, 77 structure array, 122 fields, 122 structures, 121, 122 creating, 24 manipulating, 125 subfunctions, 109 subplot , 189 sub s , 48, 49, 241 sum, surf , , , surface plot, 193 from interpolation, 203 surf c , 189, 197 surf l , 189, 197 SVD factorization, 138 switch-case-otherwise, 1 symbolic differentiation, 48 factorization, 48 integration, 48 solution of algebraic equations, 49 symbolic algebra, symbolic calculations, 48 symbolic computation, 47, 237 symbolic math, 38 Symbolic Math Toolbox, , 235 symbolic variables, 38 syms , 45 , 48, 49 syntax, 253 termination, 12 t ext , 76 text editor, t i t l e , 25, 26, 34, 176 tolerance, 162 absolute, 162 relative, 162 toolboxes, Tools menu, 150 transcendental equation, 169 transparency, 216 transpose, 69 trapz, 152 trees, 139 trigonometric functions, 19, 75 arguments in degrees, 76 arguments in radians, 76 tril, 72 trimesh, 189 trisurf , 189 triu, 72 tutorial lessons, 15 type, 31 typographical styles, help box, italics, shaded boxes, typed face, utility matrices, 70 examples, 71 variable names, 63 variable precision arithmetic, 238 vector, 65 arithmetic operations with, 21 column, 22 creating, 21, 72 input, 65 linearly spaced, 72 logarithmically spaced, 72 row, 22 vector field, 201 vectorization, 82 vectorize, 241 ver , 12 vi editor, view ( ) , 192 view ( ) , 192 volumetric plots, 201 vpa, 238 wat erf al l , 189, 198 271 www.elsolucionario.net Index 272 www.elsolucionario.net Index what , 12 , xlabel, 25, 26, 76 xlsread, 53 ylabel, 25, 26, 76 zero matrix, 69 zeros , 42, 69-71 zeros of a polynomial, 70 zoom, 77 www.elsolucionario.net 56 what snew, 253 while loop, 1 who , , 31 whos , , 31, 52 why, 253 workspace, 52 workspace information, 31 workspace information commands, 12 writing a file, 119 ... try his/her luck by sending comments to pratap@ mecheng.iisc.emet.in or www.elsolucionario.net pratap. mems@gmail.com Getting Started with www.elsolucionario.net MATLAB RUDRA PRATAP Department... Cataloging-in-Publication Data Pratap, Rudra, 1964- Getting started with MATLAB: a quick introduction for scientists and engineers / Rudra Pratap p em ISBN: 978-0-19-973124-4 MATLAB Science-Data processing... in MATLAB a user-created file with a sequence of MATLAB commands in it The file must be saved with a m exten s ion to its name, thereby, m aking it an M-jile A script file is executed by typing

Ngày đăng: 16/10/2021, 15:28

Mục lục

    4. Programming in MATLAB: Scripts and Functions

    8. Computer Algebra and The Symbolic Math Toolbox

    A. The MATLAB Language Reference

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan