Você está na página 1de 3

MathWorks News&Notes

Using MATLAB to Teach


Programming to First-Year Engineering
Students at Boston University
By Stormy Attaway, Boston University

In the 20 years that I’ve been teaching Introduction to


Engineering Computation, we’ve used several different languages, includ-
ing Pascal, Fortran, C, and C++, but the course remained fundamentally
unchanged until recently, when an engineering faculty task force met to
rethink the course objectives. Faculty from the electrical and computer
engineering department initiated the change, telling the committee that
they would like all students to learn the basic programming concepts
using MATLAB® so that students could then effectively use MATLAB
in their upper-level courses and beyond.

S ome faculty initially balked, believing


that it was a choice between MATLAB and
take longer, the resulting solutions are usu-
ally not optimized for performance.
to give them a two-page, single-spaced
handout on how to open the appropriate
introductory programming—not realizing For these reasons, in ENG EK127: In- code editor and start typing, and it took
that MATLAB has all the requisite pro- troduction to Engineering Computation an entire lecture to go through the basic
gramming constructs. we decided to take the unique approach setup steps.
It may seem at first that a biomedical of teaching programming concepts and With MATLAB, students can jump right
engineering student would only need to the built-in functions side-by-side, using in; they type commands in the Command
know how to use MATLAB efficiently and MATLAB as the vehicle for both. Each Window and immediately see the results.
that a computer systems engineer would semester, about 200 engineering students There’s no intimidation whatsoever. For
only need to know programming con- in all engineering disciplines learn how a student new to programming, this is
cepts, but in engineering today, both skill to work with variables, data structures, much easier—and more motivating—than
sets are vital. Another consideration was loops, conditionals, functions, input and the edit-compile-execute-debug cycle re-
that students who learn a low-level lan- output, and other programming concepts quired by other languages.
guage such as C++ or Java™ before learning within MATLAB and how to use MATLAB Instead of spending the first lecture
MATLAB tend to use MATLAB inefficient- efficiently to solve engineering problems. talking about how to use the development
ly, at least at first. Instead of using code environment, I can now cover assignment
vectorization techniques and the many Jumping Right In statements, variables, expressions, opera-
powerful functions built into MATLAB, One of the biggest hurdles that I faced tors, precedence, and vectors.
they rely on for-loops and other low-level when I taught the course using C++ was Students are also motivated when
constructs. Not only does this approach simply getting the students started. I had they can visualize results in new ways. I

1 Reprinted from MathWorks News&Notes | 2 0 1 0 w w w. m a t hw o r k s .c o m


Left to right, top to bottom: Dr. Attaway
lecturing on for-loops, students demonstrating the
wind turbine data collection project, a student
problem-solving in MATLAB at the chalkboard, the
course text book, an engineering building at BU,
students working with Dr. Attaway in the lab.

MATLAB plot created by students to compare DNA samples.

w w w. m a t hw o r k s .c o m Reprinted from MathWorks News&Notes | 2 0 1 0 2


cover MATLAB plots early in the semester Beyond Basic Programming Concepts those concepts. For example, students
because using a for-loop to create plots MATLAB is so easy for the students to use typically have trouble grasping the notion
and charts is much more interesting to the and learn that I can cover all the basic pro- of nested loops. When we get to matrix
students than repeatedly printing a string. gramming concepts that we used to cover operations, I show how these are imple-
using other platforms plus a great deal of mented in MATLAB by walking through the
Course Structure mathematics and basic problem-solving, MATLAB files. Students see exactly how
The course is based on my book, MATLAB: including introductions to linear algebra, nested loops work and why they work.
A Practical Introduction to Programming curve fitting, and statistical analysis. Many are surprised that a concept that was
and Problem Solving. It consists of two one- MATLAB has also enabled me to try at first difficult is now so simple to them.
hour lectures per week, each followed by an new teaching approaches. For example, It is a common misconception among
hour and a half in the computer lab. A one- in a summer class the students used the engineering faculty that teaching a com-
hour informal discussion session at the end LEGO® MINDSTORMS® NXT system and putation course using MATLAB means
of the week offers more opportunities for MATLAB to build robots and program forgoing the programming concepts. This
students to ask questions. them to navigate an obstacle course. More is not true at all. We have shown at Boston
In the lectures, I repeat the process of recently, we set up a desktop wind turbine University that you can impart program-
talking for five to ten minutes, showing in a wind tunnel and used MATLAB to ming skills, efficient coding, and basic
an example using MATLAB, and then collect and analyze data, perform curve problem-solving, all within the user-
giving the students a problem to work on. fitting, calculate the power generated, and friendly MATLAB environment. ■
Lectures used to be held in a computer run simulations.
lab, with students working on the prob-
lems directly in MATLAB. I’ve found, Positive Feedback
however, that they learn better when they In open meetings with sophomores and
think the problem through using pen and juniors who took the MATLAB based course
paper instead of immediately going to as freshmen, we heard over and over how
code. (For the same reason, tests are given pleased they were to have learned MATLAB
in a written question-and-answer format in their first year at BU. I’ve heard nothing
rather than within MATLAB.) Following but positive remarks about the course from
each lecture they work with MATLAB in the engineering faculty as well. I’m working
the lab to solve more advanced problems, with several professors to further integrate
which gives them an opportunity to im- MATLAB into the engineering curricula.
mediately apply the abstract concepts We plan, for example, to use it more exten-
they just learned. sively in the linear algebra and engineering
Working in pairs or groups of three, mechanics classes.
students complete three projects during Among the only complaints I’ve heard
the course. More complex than the ones were a few from upperclassmen who took
I give during the lab sessions, these proj- the C++ version of the course and wished
ects are designed to give students an idea that they had had an opportunity to learn
of how various engineering disciplines use MATLAB (which was then provided for
MATLAB to solve real problems. I typi- them in the form of wildly popular Satur-
cally include one project from each College day tutorials).
of Engineering department every semester. Teaching programming concepts with
Recent projects have included decoding MATLAB has yielded several advantages Resources
Learn More Online
a text message from an audio file, image that we envisioned and a few that we did
processing for quality control on turbine not. We expected that the visual, interac- MATLAB: A PRACTICAL INTRODUCTION TO
PROGRAMMING AND PROBLEM SOLVING
blades, detecting differences in images, fin- tive MATLAB environment would engage www.mathworks.com/books/attaway
gerprint recognition, finite differences for students and help them learn new con-
EXPERIMENTS WITH MATLAB
heat transfer applications, and elastic scat- cepts. It turns out that MATLAB also gives www.mathworks.com/moler/exm
tering spectroscopy for cancer detection. them a more thorough understanding of

3 91847v00 11/10 © 2010 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.

Você também pode gostar