5
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. Figure 1. The Computer Programming with MATLAB ebook. See more articles and subscribe at mathworks.com/newsletters. 1

Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

Embed Size (px)

Citation preview

Page 1: Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

Teaching Computer Programming to First-Year EngineeringStudents with MATLAB and an eBookBy Michael Fitzpatrick and Ákos Lédeczi, Vanderbilt University

The electrical engineering and computer science department at Vanderbilt University has offered a first-year computer programmingcourse for more than 30 years. Like similar courses at other universities, the content was always dictated by the needs of computerscience majors. This one-size-fits-all approach failed to engage many engineering students because engineers and computer scientistsapproach programming with divergent goals. While engineers typically create programs that they will use themselves, computerscientists 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 versatilesystem for solving problems, but it is also a dynamic programming language that can be used to learn (and teach) a full range ofcomputer 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 theprinciples, vocabulary, and methods of computer science with engineering problem-solving in an interactive format (Figure 1). Theebook is used as a textbook for a course that develops MATLAB skills early in the engineering curriculum, making it possible to covermuch more material in upper-level engineering courses that require MATLAB programming.

Figure 1. The Computer Programming with MATLAB ebook.

See more articles and subscribe at mathworks.com/newsletters.

1

Page 2: Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

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 Engineeringdecided to offer an alternative based on MATLAB. At first, while many department heads acknowledged that MATLAB was the bestlanguage for practicing engineers and scientists, they were understandably skeptical that it would support the array of programmingconstructs taught in CS 101. Before they would allow their majors to move to a course based on MATLAB, they needed to be assured thatMATLAB provided not only branching, looping, and function calling but also structures, recursion, and pointers—everything requiredfor an introductory programming course.

At a special faculty meeting, Michael presented the reasoning for selecting MATLAB for the new course. He quoted engineers from fivemajor companies who credited MATLAB with helping them become more efficient and achieve time reductions "from a week to 15minutes" and "from several months to weeks." He cited an automotive engineer’s statement that MATLAB was a de facto industrystandard. He noted the many advantages of MATLAB over traditional third-generation languages for solving engineering problems. Forexample, he showed them how a common engineering operation, matrix multiplication, is implemented with a single statement inMATLAB (X = Y*Z), contrasting that with the equivalent in the language C, which requires an error-prone, triple for-loop. Mostimportantly, 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 25slots filled up immediately. The dean’s office scheduled the course in the school’s largest classroom and took all comers. When classstarted, 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 tobe found, and furthermore, none of the available MATLAB books used standard computer-science terminology when describing featuresof the MATLAB language itself. Michael chose the best book on MATLAB he could find, Steven J. Chapman’s MATLAB Programmingfor 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 atextbook. He initially distributed Introduction to Programming with MATLAB online, chapter by chapter. In subsequent years, the bookwas 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. Inaddition to being more portable than a traditional textbook, an Apple ebook offers several other advantages. First, it can easily beupdated to include new material and reflect the latest version of MATLAB. Second, animations and videos can be included, helpingstudents understand abstract and complex subjects best illustrated with motion. The CS 103 ebook has numerous videos, including oneshowing an animated surface plot and another showing the insertion of a new node in a linked list (Figure 2).

2

Page 3: Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

Figure 2. eBook video showing the insertion of a node in a linked list.

We were careful to provide consistent, accepted definitions for all computer science terms used in the course. When students encounter anew 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 aboutthe term on Wikipedia. They can take notes, highlight text, and copy code snippets to try in MATLAB (Figure 3).

Figure 3. Student annotations showing code selected for copying (blue) and text highlighted for later review (green).

Many students use MATLAB Mobile™ on their iPad to try out new programming concepts as they learn them. MATLAB Mobile enablesthem to execute scripts and commands via a MATLAB session running on the cloud (Figure 4). Students can use this capability fromtheir dorm room or anywhere else on campus, freeing them from having to visit a computer lab or carry their laptops around toexperiment with new ideas.

3

Page 4: Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

Figure 4. The MATLAB Mobile interface on an iPad.

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 somereal 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 alesson on functions. Students learn the importance of well-defined interfaces and how to use functions to create reusable softwarecomponents. In the following weeks, we cover selection (also known as branching) using if and 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 andrecursion.

The course then covers linear algebra, including the MATLAB backslash (\) operator and inconsistent, overdetermined, andunderdetermined 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 haveincluded processing and analyzing Twitter data in MATLAB and calculating the force needed to slingshot a rocket around Jupiter andout 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 courseis also popular among science majors and other non-engineering students, and about a quarter of the more than 200 students enrolledeach 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

4

Page 5: Teaching Computer Programming to First-Year · PDF fileTeaching Computer Programming to First-Year ... Figure 1. The Computer Programming with ... students apply the concepts they

teaching MATLAB basics. In fact, we’ve tailored the course to meet the needs of other professors at Vanderbilt; for example, the lessonon 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 startedout 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 easilyaccessible online. The graphics and images were also really great and easy to understand. Lastly, I appreciated the computer version ofthe 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. Theyclearly enjoy the course and, as a result, work harder and learn more.

About the Author

Michael Fitzpatrick is a professor emeritus of computer science at Vanderbilt University. He retired in 2011 after teaching at thecollege level for 35 years, teaching computer science for 29 years, and teaching computer programming with MATLAB for 11years. He received a B.S. in physics and an M.S. in computer science from the University of North Carolina at Chapel Hill, and aPh.D. in physics from Florida State University. He uses MATLAB in his research in computer-assisted surgery.

Ákos Lédeczi is an associate professor of computer engineering and senior research scientist at the Institute for SoftwareIntegrated Systems at Vanderbilt University, where he has been teaching computer programming with MATLAB for five years.He holds an M.S. in electrical engineering from the Technical University of Budapest and a Ph.D. in electrical engineering fromVanderbilt University. His research includes model-integrated computing and wireless sensor networks.

Products Used

▪ MATLAB

Learn More

▪ Computer Programming with MATLAB, by Michael

Fitzpatrick and Ákos Lédeczi

▪ Webinar: Fostering Independent Learning and MATLAB

Programming Skills at the Introductory Level (27:32)

▪ Using MATLAB to Teach Programming to First-year

Engineering Students at Boston University

▪ Motivating First-Year UC Berkeley Students to Learn

Programming with a Virtual Robot Tournament

See more articles and subscribe at mathworks.com/newsletters.

Published 201392151v00

mathworks.com© 2013 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarksfor a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders.

5