A Note to Students

What will I be able to do after completing this book?
Imagine you are given a file that contains data of position and time of the path of a rocket. By the end of this book, you will be able to read in the data from the file(s), estimate position, velocity, and acceleration of the rocket, and plot each of these dynamics variables simply by clicking “run” on your program. The best part is, if you get new data or multiple sets of data from multiple rockets, you can get all of these results again with only minimal additional work. This is just one example of many real-world problems you will be capable of solving after mastering the material in this book.

This textbook will give you a strong foundation in programming fundamentals through MATLAB. Although some more advanced topics like object-oriented programming are beyond the scope of this book, you will be able to solve the vast majority of engineering problems you encounter in school and in the workplace using the knowledge and skills you gain from this book.

Why should I learn programming? It may be a common belief that the concepts learned in programming are only applicable to computers and computer languages. However, this is not true. The various concepts of programming, for example, a yes/no decision, are used in nearly every action we take while interacting with the world in our daily activities. For instance, you may ask yourself whether you should drink tea before going to sleep, or whether you should exercise before eating a meal.

The typical sequential structure of a computer program is also used by us as we order the events of our schedule to make sense. For instance, one would never consider putting on their shoes before their socks. Logically, an individual will first put on their socks, then their shoes and finally, they would secure the shoes.

David Malan who teaches a general computer science course CS50 at Harvard to majors and non-majors of computer science (largest course at his institution and the largest Massive Open Online Course (MOOC) on edX) sums it up the best - “More than just teach you how to program, this course teaches you how to think more methodically and how to solve problems more effectively. As such, its lessons are applicable well beyond the boundaries of computer science itself. That the course does teach you how to program, though, is perhaps its most empowering return. With this skill comes the ability to solve real-world problems in ways and at speeds beyond the abilities of most humans.”

Furthermore, programming will teach you important debugging skills that are useful in correcting all sorts of mechanical and electrical systems. You will learn the steps to identify a problem, determine its cause, and finally devise a solution. You will learn to be meticulous when comparing what you expect with what you observe.

How can I use the book most effectively? After reading each lesson, do all of the multiple-choice questions and as many exercise problems as you can (preferably all). Practice is essential when learning to program. Cramming will not work, and as with many other courses, repeated bursts of practice is the best method to grasp the material (an hour or two each day). When completing the exercises, it is highly recommended to work alone as the approach to new problems needs to be learned individually. This will make your debugging and testing skills much stronger, which will, in turn, make you a better programmer.

Pay careful attention to the “Important Notes” in the text. We have been deliberate about placing these in the lessons so that they can be helpful without being overwhelming. They are meant to be a kind of pro-tip to tell you something that some people only realize after making the mistake many times.

Also take advantage of the Index of terms, functions, and commands at the back of the book. This can be a quick way to find that one function you need to review.

How does MATLAB compare to other popular languages? MATLAB is a powerful programming language with many first-party functions and commands to do all kinds of tasks like statistics, machine learning, controls, data analysis, modeling, and user interfaces to name a few. It also has excellent documentation compared to other popular languages due, in part, to the fact that MATLAB is a proprietary language.

Learning MATLAB will give you a great foundation to transfer to other languages should you need to. Python is a popular open-source programming language that has similar syntax compared to MATLAB. Suffice it to say, MATLAB is a good choice as a first language both for its ubiquity in academia and for its stellar documentation (make sure you take advantage of this!).