Skip to main content
Engineering LibreTexts

Preface

  • Page ID
    84532
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Preface

    Modeling and simulation are powerful tools for explaining the world, making predictions, designing things that work, and making them work better. Learning to use these tools can be difficult; this book is my attempt to make the experience as enjoyable and productive as possible.

    By reading this book—and working on the exercises—you will learn some programming, some modeling, and some simulation. With basic programming skills, you can create models for a wide range of physical systems. My goal is to help you develop these skills in a way you can apply immediately to real-world problems.

    This book presents the entire modeling process, including model selection, analysis, simulation, and validation. I explain this process in Chapter , and there are examples throughout the book.

    Who This Book Is For

    To make this book accessible to the widest possible audience, I’ve tried to minimize the prerequisites.

    This book is intended for people who have never programmed before. I start from the beginning, define new terms when they are introduced, and present only the features you need, when you need them.

    I assume that you know trigonometry and some calculus, but not very much. If you understand that a derivative represents a rate of change, that’s enough. You will learn about differential equations and some linear algebra, but I will explain what you need to know as we go along.

    I will assume you know basic physics, in particular the concepts of force, acceleration, velocity, and position. If you know Newton’s second law of motion in the form \(F = m a\), that’s enough.

    Installing Software

    This book is based on MATLAB, a programming language originally developed at the University of New Mexico and now produced by MathWorks, Inc.

    MATLAB is a high-level language with features that make it well-suited for modeling and simulation, and it comes with a program development environment that makes it well-suited for beginners.

    However, one challenge for beginners is that MATLAB uses vectors and matrices for almost everything, which can make it hard to get started. The organization of this book is meant to help: we start with simple numerical computations, adding vectors in Chapter and matrices in Chapter .

    Another drawback of MATLAB is that it is “proprietary”; that is, it belongs to MathWorks, and you can only use it with a license, which can be expensive.

    Fortunately, the GNU Project has developed a free, open-source alternative called Octave (see https://www.gnu.org/software/octave).

    Most programs written in MATLAB can run in Octave without modification, and the other way around. All programs in this book have been tested with Octave, so if you don’t have access to MATLAB, you should be able to work with Octave. The biggest difference you are likely to see is in the error messages.

    To install and run MATLAB, see https://greenteapress.com/matlab/matlab.

    The first time you run it, a start window should appear to guide you through some configuration.

    To install Octave, I recommend that you use Anaconda, which is a package management system that makes it easy to work with Octave and supporting software.

    Anaconda installs everything at the user level, so you can install it without admin or root permissions. Follow the instructions for your operating system at https://greenteapress.com/matlab/anaconda.

    Once you have Anaconda, you can install Octave by launching the Jupyter Prompt (on Windows) or a Terminal (on Mac OS or Linux), typing the following, and pressing enter:

    conda install -c conda-forge octave

    Then you can launch it by typing:

    octave

    and pressing enter.

    Working with the Code

    The code for each chapter in this book is in a ZIP file you can download from https://greenteapress.com/matlab/zip. Once you have the ZIP file, you can unzip it on the command line by running

    unzip PhysicalModelingInMatlab-master.zip

    In Windows you can right-click on the ZIP file and select Extract All.

    The result should be a folder than contains subfolders that contain files containing MATLAB code. They are plain text files, so you can read them with any application that reads text, but most often you will read them with MATLAB.

    I’ll provide more information about working with these files when we get to them, but that should be enough to get you started.

    Contributors

    If you discover an error in this book or the supporting code, or you have suggestions for improving them, please send them to downey@greenteapress.com. Or, if you are a GitHub user, you can open an issue or a pull request at https://github.com/AllenDowney/PhysicalModelingInMATLAB.

    Special thanks to my collaborators at No Starch Press for their work on this book: Alex Freed, Katrina Taylor, Kelly Kearney, Barbara Yien, Bill Pollock, Richard Hutchinson, and Lisa Devoto Farrell.

    Other people who have found errors and helped improve this book include Michael Lintz, Kaelyn Stadtmueller, Roydan Ongie, Keerthik Omanakuttan, Pietro Peterlongo, Li Tao, Steven Zhang, Elena Oleynikova, Kelsey Breseman, Philip Loh, Harold Jaffe, Vidie Pong, Nik Martelaro, Arjun Plakkat, Zhen Gang Xiao, Zavier Patrick Aguila, Michael Cline, Denny Chen, Matt Wiens, and Craig Scratchley.

    • Was this article helpful?