Teaching Computer Programming to First-Year Engineering Students with MATLAB and an eBook
By Michael Fitzpatrick and Ákos Lédeczi, Vanderbilt University
The electrical engineering and computer science department at Vanderbilt University has offered a first-year computer programming course for more than 30 years. Like similar courses at other universities, the content was always dictated by the needs of computer science majors. This one-size-fits-all approach failed to engage many engineering students because engineers and computer scientists approach programming with divergent goals. While engineers typically create programs that they will use themselves, computer scientists typically create programs for use by non-programmers.
At Vanderbilt today, we use MATLAB® to span the divide between engineering and computer science. MATLAB provides a versatile system for solving problems, but it is also a dynamic programming language that can be used to learn (and teach) a full range of computer science concepts—from conditionals and variables to recursion and object-oriented programming.
To help first-year engineering students learn programming with MATLAB, we have developed an Apple® ebook that combines the principles, vocabulary, and methods of computer science with engineering problem-solving in an interactive format (Figure 1). The ebook is used as a textbook for a course that develops MATLAB skills early in the engineering curriculum, making it possible to cover much more material in upper-level engineering courses that require MATLAB programming.
Introductory Computer Science at Vanderbilt
Over the years, CS 101: Programming and Problem Solving has been taught using a variety of languages, including Fortran, Pascal, C, C++, and Java™.
In 2000, in order to address the frustration engineering students were experiencing with CS 101, Vanderbilt’s School of Engineering decided to offer an alternative based on MATLAB. At first, while many department heads acknowledged that MATLAB was the best language for practicing engineers and scientists, they were understandably skeptical that it would support the array of programming constructs taught in CS 101. Before they would allow their majors to move to a course based on MATLAB, they needed to be assured that MATLAB provided not only branching, looping, and function calling but also structures, recursion, and pointers—everything required for an introductory programming course.
At a special faculty meeting, Michael presented the reasoning for selecting MATLAB for the new course. He quoted engineers from five major companies who credited MATLAB with helping them become more efficient and achieve time reductions “from a week to 15 minutes” and “from several months to weeks.” He cited an automotive engineer’s statement that MATLAB was a de facto industry standard. He noted the many advantages of MATLAB over traditional third-generation languages for solving engineering problems. For example, he showed them how a common engineering operation, matrix multiplication, is implemented with a single statement in MATLAB (
X = Y*Z), contrasting that with the equivalent in the language C, which requires an error-prone, triple for-loop. Most importantly, he promised the faculty that the new course would cover all the topics in CS 101.
In January 2001 the school offered CS 103: Introductory Programming for Engineers and Scientists, with a limit of 25 students. The 25 slots filled up immediately. The dean’s office scheduled the course in the school’s largest classroom and took all comers. When class started, 68 students were enrolled. The following year, there were 111.
Creating the eBook
The first challenge for CS 103 was to find a textbook that included MATLAB and structures, recursion, and pointers. There were none to be found, and furthermore, none of the available MATLAB books used standard computer-science terminology when describing features of the MATLAB language itself. Michael chose the best book on MATLAB he could find, Steven J. Chapman’s MATLAB Programming for Engineers, and wrote supplementary material to fill in the missing pieces.
A few years later, working with graduate student and teaching assistant John Crocetti, he expanded the supplementary material into a textbook. He initially distributed Introduction to Programming with MATLAB online, chapter by chapter. In subsequent years, the book was provided as a PDF document at the beginning of each semester.
In 2012, we seized an opportunity to write a new, updated textbook as an ebook, making it available to students with iPad devices. In addition to being more portable than a traditional textbook, an Apple ebook offers several other advantages. First, it can easily be updated to include new material and reflect the latest version of MATLAB. Second, animations and videos can be included, helping students understand abstract and complex subjects best illustrated with motion. The CS 103 ebook has numerous videos, including one showing an animated surface plot and another showing the insertion of a new node in a linked list (Figure 2).
We were careful to provide consistent, accepted definitions for all computer science terms used in the course. When students encounter a new term in the ebook, with a single tap they can see a definition, jump to the glossary, or even switch to a browser and read more about the term on Wikipedia. They can take notes, highlight text, and copy code snippets to try in MATLAB (Figure 3).
Many students use MATLAB Mobile™ on their iPad to try out new programming concepts as they learn them. MATLAB Mobile enables them to execute scripts and commands via a MATLAB session running on the cloud (Figure 4). Students can use this capability from their dorm room or anywhere else on campus, freeing them from having to visit a computer lab or carry their laptops around to experiment with new ideas.
Programming Concepts Covered in CS 103
To bring students without programming experience up to speed, we start CS 103 with a two-week introduction to visual programming, using the Scratch environment from the MIT Media Lab. Following that simplified lesson, we tell the students it is time to begin some real programming, and we follow the topics covered in the ebook.
After introducing the MATLAB environment, including matrices and operators, we teach procedural programming, beginning with a lesson on functions. Students learn the importance of well-defined interfaces and how to use functions to create reusable software components. In the following weeks, we cover selection (also known as branching) using
switch statements, loops, data types, and file input/output. We then take a more in-depth look at functions, introducing functions with a variable number of arguments and recursion.
The course then covers linear algebra, including the MATLAB backslash (
\) operator and inconsistent, overdetermined, and underdetermined equations. The final lessons cover searching, including sequential and binary searches, and sorting algorithms, including selection sort and merge sort.
CS 103 concludes with a project in which the students apply the concepts they have learned throughout the semester. Past projects have included processing and analyzing Twitter data in MATLAB and calculating the force needed to slingshot a rocket around Jupiter and out of the solar system, for example.
CS 103 Today
CS 103 is now a required course for first-year civil, chemical, mechanical, and biomedical engineering students at Vanderbilt. The course is also popular among science majors and other non-engineering students, and about a quarter of the more than 200 students enrolled each semester take the course as an elective.
In addition to its growing popularity among students, the course has garnered the approval of engineering faculty across departments. Because students now learn MATLAB in their first year, professors in upper-level courses no longer have to spend valuable class time teaching MATLAB basics. In fact, we’ve tailored the course to meet the needs of other professors at Vanderbilt; for example, the lesson on file input and output, with an associated section in the ebook, was added based on faculty suggestions.
As for the ebook, it has been well received by the students. One student commented, “I really enjoyed the textbook. The examples started out simple and easy to understand and progressed to more challenging throughout each chapter. The commentary throughout was fun, and the functions at the back of the chapter really helped me practice the concepts. It was nice that half the solutions were easily accessible online. The graphics and images were also really great and easy to understand. Lastly, I appreciated the computer version of the textbook, which made it easy to carry around. Made my class much more enjoyable.”
In CS 101, engineering students felt like misfits in a course geared toward computer scientists. In CS 103, that is no longer the case. They clearly enjoy the course and, as a result, work harder and learn more.
Published 2013 - 92151v00