Download MATLAB For Dummies by Jim Sizemore

MATLAB For Dummies by Jim Sizemore

MATLAB For Dummies – If you work in a STEM field, chances are you’ll be using MATLAB on a daily basis. MATLAB is a popular and powerful computational tool and this book provides everything you need to start manipulating and plotting your data.

MATLAB has rapidly become the premier data tool, and MATLAB For Dummies is a comprehensive guide to the fundamentals. MATLAB For Dummies guides you through this complex computational language from installation to visualization to automation.

  • Learn MATLAB’s language fundamentals including syntax, operators, and data types
  • Understand how to use the most important window in MATLAB – the Command Window
  • Get the basics of linear algebra to get up and running with vectors, matrices, and hyperspace
  • Automate your work with programming scripts and functions
  • Plot graphs in 2D and 3D to visualize your data
  • Includes a handy guide for MATLAB’s functions and plotting routines

MATLAB is an essential part of the analysis arsenal and MATLAB For Dummies provides clear, thorough guidance to get the most out of your data.

From the Back Cover

Learn to:

  • Work with this high-level language and problem-solving environment
  • Use MATLAB to analyze data, develop algorithms, and create models
  • Develop numerical computations and plots
  • Automate your work with scripts

A complete and easy-to-use guide to the popular MATLAB software tool

If you’re working in a STEM field, chances are you need to know MATLAB. Get up and running with MATLAB in a flash with this comprehensive, yet easy-to-use guide to one of the most popular computational tools on the market! Explore the software’s functionality and navigation as well as its extensive math functions, find out how to use advanced features, and much more!

  • Dive right in — find out the basics of MATLAB, important knowledge on how to use it, and how to interact with this popular tool
  • Manipulate data — get into the meat and potatoes of MATLAB by working with vectors, matrices, and higher dimensions
  • Get streamlined — automate your work with scripts, expand on MATLAB’s built-in functions, and dive into conditional statements
  • The sum of its parts — discover the practical parts of MATLAB, including details on saving, importing, exporting, printing, and publishing
  • MATLAB applications — explore the specific MATLAB applications, solve equations and find roots, and get into linear algebra, calculus, and more
  • Displaying the results — use MATLAB’s extensive collection of plots to see the results of your computations and present them in reports that communicate your ideas to others

Open the book and find:

  • How MATLAB is used in STEM fields
  • What you need to get started using MATLAB
  • How to work with math syntax and MATLAB
  • Tricks to starting, storing, and saving files
  • Details on plotting data with 2D and 3D data
  • Tips on automating your work in MATLAB
  • Everything you need to know about control structures
  • How to recover from the most common mistakes

Table of Contents – MATLAB For Dummies

Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Part I: Getting Started With MATLAB
Chapter 1: Introducing MATLAB and Its Many Uses
Putting MATLAB in Its Place
Understanding how MATLAB relates to a Turing machine
Using MATLAB as more than a calculator
Determining why you need MATLAB
Discovering Who Uses MATLAB for Real-World Tasks
Knowing How to Get the Most from MATLAB
Getting the basic computer skills
Defining the math requirements
Applying what you know about other procedural languages
Understanding how this book will help you
Getting Over the Learning Curve
Chapter 2: Starting Your Copy of MATLAB
Installing MATLAB
Discovering which platforms MATLAB supports
Getting your copy of MATLAB
Performing the installation
Activating the product
Meeting the MATLAB Interface
Starting MATLAB for the first time
Employing the Command window
Using the Current Folder toolbar
Viewing the Current Folder window
Changing the MATLAB layout
Chapter 3: Interacting with MATLAB
Using MATLAB as a Calculator
Entering information at the prompt
Entering a formula
Copying and pasting formulas
Changing the Command window formatting
Suppressing Command window output
Understanding the MATLAB Math Syntax
Adding, subtracting, multiplying, and dividing
Working with exponents
Organizing Your Storage Locker
Using ans — the default storage locker
Creating your own storage lockers
Operating MATLAB as More Than a Calculator
Learning the truth
Using the built-in functions
Accessing the function browser
Recovering from Mistakes
Understanding the MATLAB error messages
Stopping MATLAB when it hangs
Getting Help – MATLAB For Dummies
Exploring the documentation
Working through the examples
Relying on peer support
Obtaining training
Requesting support from MathWorks
Contacting the authors
Chapter 4: Starting, Storing, and Saving MATLAB Files
Examining MATLAB’s File Structure
Understanding the MATLAB files and what they do
Exploring folders with the GUI
Exploring folders with commands
Working with files in MATLAB
Accessing and Sharing MATLAB Files
Opening
Importing
Exporting – MATLAB For Dummies
Saving Your Work
Saving variables with the GUI
Saving variables using commands
Saving commands with the GUI
Saving commands using commands
Part II: Manipulating and Plotting Data in MATLAB
Chapter 5: Embracing Vectors, Matrices, and Higher Dimensions
Working with Vectors and Matrices
Understanding MATLAB’s perspective of linear algebra
Entering data
Adding and Subtracting
Understanding the Many Ways to Multiply and Divide
Performing scalar multiplication and division
Employing matrix multiplication
Effecting matrix division
Creating powers of matrices
Working element by element
Using complex numbers
Working with exponents
Working with Higher Dimensions
Creating a multidimensional matrix
Accessing a multidimensional matrix
Replacing individual elements
Replacing a range of elements
Modifying the matrix size
Using cell arrays and structures
Using the Matrix Helps
Chapter 6: Understanding Plotting Basics
Considering Plots
Understanding what you can do with plots
Comparing MATLAB plots to spreadsheet graphs
Creating a plot using commands
Creating a plot using the Workspace window
Creating a plot using the Plots tab options
Using the Plot Function
Working with line color, markers, and line style
Creating multiple plots in a single command
Modifying Any Plot
Making simple changes
Adding to a plot – MATLAB For Dummies
Deleting a plot
Working with subplots
Plotting with 2D Information
Chapter 7: Using Advanced Plotting Features
Plotting with 3D Information
Using the bar() function to obtain a flat 3D plot
Using bar3() to obtain a dimensional 3D plot
Using barh() and more
Enhancing Your Plots
Getting an axes handle
Modifying axes labels
Adding a title
Rotating label text
Employing annotations
Printing your plot
Part III: Streamlining MATLAB
Chapter 8: Automating Your Work
Understanding What Scripts Do
Creating less work for yourself
Defining when to use a script
Creating a Script
Writing your first script
Using commands for user input
Copying and pasting into a script
Converting the Command History into a script
Continuing long strings
Adding comments to your script
Revising Scripts
Calling Scripts
Improving Script Performance
Analyzing Scripts for Errors
Chapter 9: Expanding MATLAB’s Power with Functions
Working with Built-in Functions
Learning about built-in functions
Sending data in and getting data out
Creating a Function
Understanding script and function differences
Understanding built-in function and custom function differences
Writing your first function
Using the new function
Passing data in
Passing data out – MATLAB For Dummies
Creating and using global variables
Using subfunctions
Nesting functions
Using Other Types of Functions
Inline functions
Anonymous functions
Chapter 10: Adding Structure to Your Scripts
Making Decisions
Using the if statement
Using the switch statement
Understanding the switch difference
Deciding between if and switch
Creating Recursive Functions
Performing Tasks Repetitively
Using the for statement
Using the while statement
Ending processing using break
Ending processing using return
Determining which loop to use
Creating Menus
Part IV: Employing Advanced MATLAB Techniques
Chapter 11: Importing and Exporting Data
Importing Data
Performing import basics
Importing mixed strings and numbers
Defining the delimiter types
Importing selected rows or columns
Exporting Data
Performing export basics
Exporting scripts and functions
Working with Images
Exporting images
Importing images
Chapter 12: Printing and Publishing Your Work
Using Commands to Format Text
Modifying font appearance
Using special characters
Adding math symbols
Publishing Your MATLAB Data
Performing advanced script and function publishing tasks
Saving your figures to disk
Printing Your Work
Configuring the output page
Printing the data
Chapter 13: Recovering from Mistakes
Working with Error Messages
Responding to error messages
Understanding the MException class
Creating error and warning messages
Setting warning message modes
Understanding Quick Alerts
Relying on Common Fixes for MATLAB’s Error Messages
Making Your Own Error Messages
Developing the custom error message
Creating useful error messages
Using Good Coding Practices
Part V: Specific MATLAB Applications
Chapter 14: Solving Equations and Finding Roots
Working with the Symbolic Math Toolbox
Obtaining your copy of the Toolbox
Installing the Symbolic Math Toolbox
Working with the GUI
Typing a simple command in the Command window
Performing Algebraic Tasks
Differentiating between numeric and symbolic algebra
Solving quadratic equations
Working with cubic and other nonlinear equations
Understanding interpolation
Working with Statistics – MATLAB For Dummies
Understanding descriptive statistics
Understanding robust statistics
Employing least squares fit
Chapter 15: Performing Analysis
Using Linear Algebra
Working with determinants
Performing reduction
Using eigenvalues
Understanding factorization
Employing Calculus
Working with differential calculus
Using integral calculus
Working with multivariate calculus
Solving Differential Equations
Using the numerical approach
Using the symbolic approach
Chapter 16: Creating Super Plots
Understanding What Defines a Super Plot
Using the Plot Extras
Using grid()
Obtaining the current axis using gca
Creating axis dates using datetick()
Creating plots with colorbar()
Interacting with daspect
Interacting with pbaspect
Working with Plot Routines
Finding data deviations using errorbar()
Ranking related measures using pareto()
Plotting digital data using stairs()
Showing data distribution using stem()
Drawing images using fill
Displaying velocity vectors using quiver()
Displaying velocity vectors using feather()
Displaying velocity vectors using compass()
Working with polar coordinates using polar()
Displaying angle distribution using rose()
Spotting sparcity patterns using spy()
Employing Animation
Working with movies
Working with objects
Performing data updates
Part VI: The Part of Tens
Chapter 17: Top Ten Uses of MATLAB
Engineering New Solutions
Getting an Education
Working with Linear Algebra
Performing Numerical Analysis
Getting Involved in Science
Engaging Mathematics
Exploring Research
Walking through a Simulation
Employing Image Processing
Embracing Programming Using Computer Science
Chapter 18: Ten Ways to Make a Living Using MATLAB
Working with Green Technology
Looking for Unexploded Ordinance
Creating Speech Recognition Software
Getting Disease under Control
Becoming a Computer Chip Designer
Keeping the Trucks Rolling
Creating the Next Generation of Products
Designing Equipment Used in the Field
Performing Family Planning
Reducing Risks Using Simulation
Appendix A: MATLAB Functions
Appendix B: MATLAB’s Plotting Routines

Introduction – MATLAB For Dummies

MATLAB is an amazing product that helps you perform math-related tasks of all sorts using the same techniques that you’d use if you were performing the task manually (using pencil and paper, slide rule, or abacus if necessary, but more commonly using a calculator). However, MATLAB makes it possible to perform these tasks at a speed that only a computer can provide. In addition, using MATLAB reduces errors, streamlines many tasks, and makes you more efficient. However, MATLAB is also a big product that has a large number of tools and a significant number of features that you might never have used in the past. For example, instead of simply working with numbers, you now have the ability to plot them in a variety of ways that help you better communicate the significance of your data to other people. In order to get the most from MATLAB, you really need a book like MATLAB For Dummies.

About This Book

The main purpose of MATLAB For Dummies is to reduce the learning curve that is a natural part of using a product that offers as much as MATLAB does. When you first start MATLAB, you might become instantly overwhelmed by everything you see. This book helps you get past that stage and become productive quickly so that you can get back to performing amazing feats of math wizardry. In addition, this book is designed to introduce you to techniques that you might not know about or even consider because you haven’t been exposed to them before.

For example, MATLAB provides a rich plotting environment that not only helps you communicate better, but also makes it possible to present numeric information in a manner that helps others see your perspective. Using scripts and functions will also reduce the work you do even further and this book shows you how to create custom code that you can use to customize the environment to meet your specific needs. After you’ve successfully installed MATLAB on whatever computer platform you’re using, you start with the basics and work your way up. By the time you finish working through the examples in this book, you’ll be able to perform a range of simple tasks in MATLAB that includes writing scripts, writing functions, creating plots, and performing advanced equation solving. No, you won’t be an expert, but you will be able to use MATLAB to meet specific needs in the job environment.

To make absorbing the concepts even easier, this book uses the following
conventions:
✓ Text that you’re meant to type just as it appears in the book is bold. The
exception is when you’re working through a step list: Because each step
is bold, the text to type is not bold.
✓ When you see words in italics as part of a typing sequence, you need to
replace that value with something that works for you. For example, if
you see “Type Your Name and press Enter,” you need to replace Your
Name with your actual name.
✓ Web addresses and programming code appear in monofont. If you’re
reading a digital version of this book on a device connected to the
Internet, note that you can click the web address to visit that website,
like this: http://www.dummies.com.
✓ When you need to type command sequences, you see them separated
by a special arrow like this: File➪New File. In this case, you go to the File
menu first and then select the New File entry on that menu. The result is
that you see a new file created.

Foolish Assumptions – MATLAB For Dummies

You might find it difficult to believe that we’ve assumed anything about you — after all, we haven’t even met you yet! Although most assumptions are indeed foolish, we made these assumptions to provide a starting point for the book. It’s important that you’re familiar with the platform you want to use because the book doesn’t provide any guidance in this regard. (Chapter 2 does provide MATLAB installation instructions.) To provide you with maximum information about MATLAB, this book doesn’t discuss any platform-specific issues. You really do need to know how to install applications, use applications, and generally work with your chosen platform before you begin working with this book. This book isn’t a math primer. Yes, you see lots of examples of complex math, but the emphasis is on helping you use MATLAB to perform math tasks rather than learn math theory. Chapter 1 provides you with a better understanding of precisely what you need to know from a math perspective in order to use this book successfully. This book also assumes that you can access items on the Internet. Sprinkled throughout are numerous references to online material that will enhance your learning experience. However, these added sources are useful only if you actually find and use them.

About the Author

Jim Sizemore is Professor of Physics and Engineering at Tyler Junior College. For over 25 years he’s worked in the semiconductor and software industries as a process engineer, device physicist, and software developer and has been teaching college physics, engineering, and math for the last 13 years. John Paul Mueller is a freelance author and a technical editor for both Data Based Advisor and Coast Compute magazines. He has produced 96 books and more than 300 articles to date and has been following MATLAB development for nearly a decade.

Share this:

Comment