Description
Book SynopsisMATLAB can run Python code!
Python for MATLAB Development shows you how to enhance MATLAB with Python solutions to a vast array of computational problems in science, engineering, optimization, statistics, finance, and simulation. It is three books in one:
A thorough Python tutorial that leverages your existing MATLAB knowledge with a comprehensive collection of MATLAB/Python equivalent expressions
A reference guide to setting up and managing a Python environment that integrates cleanly with MATLAB
A collection of recipes that demonstrate Python solutions invoked directly from MATLAB
This book shows how to call Python functions to enhance MATLAB''s capabilities. Specifically, you''ll see how Python helps MATLAB:
- Run faster with numba
- Distribute work to a compute cluster with dask
- Find symbolic solutions to integrals, derivatives, and series summations with
Table of Contents
Chapter 1: Introduction Goal: Describe the book’s goals, what to expect, what benefit to gain. • Learn Python through MATLAB Equivalents • Is Python really free? • What About Toolboxes? • I already know Python. How do I call Python functions in MATLAB? • What you won’t find in this book • Beyond MATLAB
Part I – Learning Python through MATLAB comparisons
Chapter 2: Installation Goal: Create a working Python installation on the computer with MATLAB • Downloads • Post-Install Checkout • ipython, IDE’s • Python and MATLAB Versions Used in This Book
Chapter 3: Language Basics Goal: Learn the basic mechanics of Python • Assignment • Printing • Indentation • Indexing • `for` Loops • `while` Loops • `if` Statements • Functions • Comments • Line Continuation • Exceptions • Modules and Packages
Chapter 4: Data Containers Goal: Learn about lists, dictionaries, etc, and how these compare to MATLAB matrices and cell arrays • NumPy Arrays • Strings • Python Lists and MATLAB Cell Arrays • Python Tuples • Python Sets and MATLAB Set Operations • Python Dictionaries and MATLAB Maps • Structured Data • Tables • Caveat: ```=`'' copies a reference for non-scalars!
Chapter 5: Date and Time Goal: Learn about measuring, storing, and converting temporal values. • Time • Dates • Timezones • Time Conversions to and from `datetime` Objects
Chapter 6: Input and Output Goal: Learn about reading and writing data, with emphasis on numeric data and scientific file formats like HDF and NetCDF. • Reading and Writing Text Files • Reading and Writing Binary Files • Reading and Writing Pickle Files • Reading and Writing `.mat` files • Command Line Input • Interactive Input • Receiving and Sending over a Network • Interacting with Databases
Chapter 7: Interacting with the File System Goal: Show how Python manages file system operations. • Reading Directory Contents • Finding Files • Deleting Files • Creating Directories • Deleting Directories • Walking Directory Trees
Chapter 8: Interacting with the Operating System and External Executables Goal: Show how to make system calls in Python and how these differ from MATLAB. • Reading, setting environment variables • Calling External Executables • Inspecting the Process Table and Process Resources
Part II – MATLAB with Python
Chapter 9: MATLAB/Python Integration Goal: Show how to make system calls in Python and how these differ from MATLAB. • MATLAB’s `py` Module • System calls and File I/O • TCP/IP Exchange
Chapter 10: Object Oriented ProgrammingGoal: Demonstrate Python’s OO semantics compared to MATLAB • Classes • Custom Exceptions • Performance Implications
Chapter 11: NumPy and SciPy Goal: Introduce Python’s numeric and scientific computing capability. This is by far the largest chapter in the book. • NumPy Arrays • Linear Algebra • Sparse Matrices • Interpolation • Curve Fitting • Statistics • Finding Roots • Optimization • Differential Equations • Symbolic Mathematics • Unit Systems
Chapter 12: Plotting Goal: Demonstrate how publication-quality plots are produced in Python alongside MATLAB equivalents • Point and Line Plots • Area Plots • Animations • Plotting on Maps • 3D Plots • Making plots in batch mode
Chapter 13: Tables and DataframesGoal: Show Pandas dataframes in comparison to MATLAB tables (and how the former pre-dates the latter by five years) • Loading tables from files • Table summaries • Cleaning data • Creating tables programmatically • Sorting rows • Table subsets • Iterating over rows • Pivot tables • Adding columns • Deleting columns • Joins across tables
Chapter 14: High Performance ComputingGoal: Demonstrate techniques for profiling Python code and making computationally intensive Python code run faster. Significant performance advantages over MATLAB are shown. • Paths to faster Python code • Reference Problems • Reference Hardware and OS • Baseline performance • Profiling Python Code • Vectorization • Cython • Pythran • Numba • Linking to C, C++, Fortran • Distributed memory parallel processing
Chapter 15: `py` Module ExamplesGoal: A collection of examples that show how Python enables the core MATLAB product to perform tasks that would either require a Toolbox or less-vetted code from the MathWorks’ user contributed FileExchange. • Read a YAML File • Write a YAML File • Compute Laplace Transforms • Interact with Redis • Units • Propagate a satellite’s orbit • Controls • Plotting on maps
Chapter 16: Language Warts Goal: Identify MATLAB and Python language ‘features’ that often cause beginners grief. • Dangerous language features • MATLAB • Python • Common Errors