Introduction 1 About This Book 1 Foolish Assumptions 2 Icons Used in This Book 3 Beyond the Book 4 Where to Go from Here 4 Part 1: Getting Started With MATLAB 7 Chapter 1: Introducing MATLAB and Its Many Uses 9 Putting MATLAB in Its Place 10 Understanding how MATLAB relates to a Turing machine 10 Using MATLAB as more than a calculator 13 Determining why you need MATLAB 14 Discovering Who Uses MATLAB for Real-World Tasks 17 Knowing How to Get the Most from MATLAB 18 Getting the basic computer skills 18 Defining the math requirements 19 Applying what you know about other procedural languages 19 Understanding how this book will help you 20 Getting Over the Learning Curve 20 Chapter 2: Starting Your Copy of MATLAB 21 Installing MATLAB 22 Discovering which platforms MATLAB supports 22 Getting your copy of MATLAB 23 Performing the installation 23 Activating the product 24 Meeting the MATLAB Interface 25 Starting MATLAB for the first time 25 Considering the default Toolstrip tabs 27 Working with the Quick Access toolbar (QAT) 29 Employing the Command Window 30 Getting additional help with MATLAB 31 Using the Current Folder toolbar 32 Viewing the Current Folder window 32 Changing the MATLAB layout 38 Chapter 3: Interacting with MATLAB 41 Using MATLAB as a Calculator 42 Entering information at the prompt 42 Entering a formula 44 Copying and pasting formulas 44 Changing the Command Window formatting 46 Suppressing Command Window output 47 Understanding the MATLAB Math Syntax 48 Adding, subtracting, multiplying, and dividing 48 Working with exponents 50 Organizing Your Storage Locker 51 Using ans -- the default storage locker 52 Creating your own storage lockers 52 Operating MATLAB as More Than a Calculator 54 Learning the truth 54 Using the built-in functions 54 Accessing the function browser 56 Recovering from Mistakes 57 Understanding the MATLAB error messages 58 Stopping MATLAB when it hangs 58 Chapter 4: Starting, Storing, and Saving MATLAB Files 61 Examining MATLAB''s File Structure 62 Understanding the MATLAB files and what they do 63 Exploring folders with the GUI 65 Exploring folders with commands 69 Working with files in MATLAB 72 Accessing and Sharing MATLAB Files 74 Opening 74 Exporting 75 Importing 76 Saving Your Work 78 Saving variables with the GUI 78 Saving variables using commands 78 Saving commands with the GUI 79 Saving commands using commands 79 Using online storage 80 Part 2: Manipulating and Plotting Data in MATLAB 81 Chapter 5: Embracing Vectors, Matrices, and Higher Dimensions 83 Working with Vectors and Matrices 84 Understanding MATLAB''s perspective of linear algebra 84 Entering data 86 Adding and Subtracting 92 Understanding the Many Ways to Multiply and Divide 94 Performing scalar multiplication and division 94 Employing matrix multiplication 95 Dividing two vectors 98 Effecting matrix division 98 Creating powers of matrices 101 Using complex numbers 102 Working with exponents 104 Working with Higher Dimensions 105 Creating a multidimensional matrix 105 Accessing a multidimensional matrix 108 Replacing individual elements 109 Replacing a range of elements 110 Modifying the matrix size 112 Using cell arrays and structures 113 Using the Matrix Helps 117 Chapter 6: Understanding Plotting Basics 121 Considering Plots 121 Understanding what you can do with plots 122 Comparing MATLAB plots to spreadsheet graphs 122 Creating a plot using commands 123 Creating a plot using the Workspace window 125 Creating a plot using the Plots tab options 126 Using the Plot Function 128 Working with line color, markers, and line style 128 Creating multiple plots in a single command 129 Modifying Any Plot 130 Making simple changes 130 Adding to a plot 132 Deleting a plot 134 Working with subplots 134 Plotting with 2D Information 137 Chapter 7: Using Advanced Plotting Features 139 Plotting with 3D Information 140 Using the bar() function to obtain a flat 3D plot 140 Using bar3() to obtain a dimensional 3D plot 144 Using barh() and more 146 Enhancing Your Plots 147 Getting an axes handle 147 Modifying axes labels 148 Adding a title 150 Rotating label text 151 Employing annotations 153 Printing your plot 154 Using the Plot Extras 155 Creating axes dates using datetick() 155 Creating plots with colorbar() 157 Interacting with daspect 159 Interacting with pbaspect 161 Part 3: Streamlining MATLAB 163 Chapter 8: Automating Your Work 165 Understanding What Scripts Do 166 Creating less work for yourself 166 Defining when to use a script 167 Creating a Script 168 Writing your first script 168 Using commands for user input 170 Copying and pasting into a script 171 Converting the Command History into a script 172 Continuing long strings 172 Adding comments to your script 174 Revising Scripts 179 Calling Scripts 179 Improving Script Performance 180 Analyzing Scripts for Errors 181 Using the MATLAB Profiler to Improve Performance 182 Chapter 9: Expanding MATLAB''s Power with Functions 185 Working with Built-in Functions 186 Learning about built-in functions 186 Sending data in and getting data out 191 Creating a Function 191 Understanding script and function differences 192 Understanding built-in function and custom function differences 193 Writing your first function 193 Using the new function 195 Passing data in 196 Passing data out 198 Creating and using global variables 199 Using subfunctions 202 Nesting functions 203 Using Other Types of Functions 204 Inline functions 204 Anonymous functions 205 Chapter 10: Adding Structure to Your Scripts 207 Making Decisions 208 Using the if statement 208 Using the switch statement 212 Understanding the switch difference 214 Deciding between if and switch 214 Creating Recursive Functions 215 Performing Tasks Repetitively 219 Using the for statement 219 Using the while statement 220 Starting a new loop iteration using continue 221 Ending processing using break 222 Ending processing using return 223 Determining which loop to use 225 Creating Menus 225 Chapter 11: Working with Live Scripts 229 Comparing a Live Script to a Regular Script 230 Working with the Live Editor 231 Opening the Live Editor 232 Working with the Output pane 232 Adding formatted text 235 Using plots within the coded area 236 Incorporating graphics 237 Incorporating controls 238 Running Live Script Sections 241 Diagnosing Coding Errors 242 Chapter 12: Working with Live Functions 245 Comparing a Live Function to a Regular Function 246 Understanding Live Function Flexibility Differences 247 Creating a Live Function 247 Running a Live Function 248 Refactoring a Live Function 249 Using the specialized coding buttons 253 Going to a specific function 254 Converting a Function to a Live Function 255 Sharing Live Functions and Live Scripts 256 Using an interactive document 256 Employing a full screen presentation 257 Working with plain text 257 Creating a static document 257 Performing Comparisons and Merges 259 Comparing Live Functions and Live Scripts 259 Merging Live Functions and Live Scripts 260 Chapter 13: Designing and Using Classes 263 A Brief Overview of Object-Oriented Programming (OOP) 264 Defining an object 264 Considering how properties define an object 265 Using methods to interact with an object 266 Listening to an object using events 267 Understanding the need for privacy 268 Understanding OOP in MATLAB 268 Comparing MATLAB OOP to other languages 269 Uses of classes and objects in MATLAB 270 Performing tasks with objects in MATLAB 271 Creating a Basic MATLAB Class 272 Starting the class 272 Adding properties 275 Specifying methods 278 Chapter 14: Creating MATLAB Apps 281 Working with the App Designer 282 Understanding apps 282 Getting apps 283 Starting the App Designer 286 Defining an Interface 290 Understanding the various components 290 Changing the component properties 292 Making the Interface Functional 293 Working with Code View 294 Creating a callback function 295 Running the App 297 Packaging Your App 298 Chapter 15: Building Projects 301 Considering the Need for Projects 302 Creating a New Project 303 Choosing a project type 303 Using the Pro.
MATLAB for Dummies