You are on page 1of 6

Session T1A

Matlab for First-year College Engineers


Alexander Haubold
Columbia University, Fu Foundation School of Engineering and Applied Science,
New York, NY 10027
ah297@columbia.edu

Abstract - We present our approach to introducing Matlab offers standardization, which is not available in comparable
to first-year engineering students without declared majors. packages.
Matlab is a widespread tool for computation, which has We teach Matlab in our first-year undergraduate
experienced a significant increase in usage. Upper-level engineering design course to give students an early albeit
courses in particular require students to complete broad introduction to a tool, which they will inevitably use in
assignments and projects using this versatile software. higher-level courses [2]. Engineering students do not declare
However, without a separate required course offering in their major until the second year, making it important to not
the first-year curriculum, students oftentimes find direct the material at any one major. The instructional material
themselves learning Matlab once they reach advanced is therefore designed to convey fundamental knowledge about
courses. Taking into account the various applications of Matlab, and introduce a few selected topics for popular
Matlab for different departments and first-year students majors.
who are undecided on their majors, a separate course for
Matlab may prove excessive and lack sufficient focus. COURSE OBJECTIVES
We embed a sequence of six Matlab lectures in an In our first-year undergraduate engineering course, students
introductory engineering design course required by all are introduced to the field of engineering design through
first-year engineering students. The lectures focus on community service learning while they work in teams of three
introducing the fundamental data structure of a matrix, to eight members [3]. Teams work on various community
programming constructs of loops, conditionals, and projects in categories such as disabilities, environment,
functions, and basic numerical and graphical statistical education, architectural designs, and information technology.
analysis. The selection of topics accounts for some of the The course approaches first-year engineering as a practical
most common applications across engineering majors, introduction while conforming with several ABET criteria,
drawing playful examples from image and signal including development of professional and communication
processing and statistical analysis. skills, practice in application of engineering principles, and
We discuss our experiences and curriculum developments focus on formulation, research, and solution finding for
for a period of four years over which the Matlab sequence engineering problems.
evolved. We also address some of the logistical matters of A typical student project involves a real client from the
using homework assignments versus examinations. community who presents a real problem to a student team.
Students research the problem space, suggest solutions, and
Index Terms – Engineering design, first-year curriculum, work on a selected solution for the duration of the semester.
Matlab, numerical computation. The client interacts with students on a continual basis and
INTRODUCTION ensures that the proposed solution meets the criteria. Clients
include public school administration, staff from after school
Mathworks Matlab has experienced a significant increase in programs, and managers from non-for-profit organizations. To
usage in engineering classrooms [1]. Where traditionally date, students have worked with the New York City
programming languages like C, Fortran, and Java were Department of Parks, various public schools in particular in
selectively required for students to homework assignments low-income areas of New York, organizations catering to
and projects, Matlab has found wide acceptance as a children with disabilities, and over 50 other organizations and
numerical computation tool. With its universal approach to individuals. Students typically provide prototype solutions by
using the matrix as a fundamental data structure, its large the end of the course, whether in physical form or through the
library of pre-made functions, and readily available tools for use of 3D modeling software. The design process for all
audio and image manipulation, Matlab finds application in all projects include background research, market analysis,
fields of engineering. Faculty has recognized this advantage interviews with clients, presentations on preliminary results,
over the alternative of using other programming languages for design and construction of solutions, and delivery of
numerical computation in the classroom. With Matlab, completed products in a final presentation.
students are no longer burdened by the high overhead of Our instruction on Matlab and related engineering topics
acquiring language-specific knowledge. In many ways, Matlab specifically facilitates stages of technical research, data

1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI


37th ASEE/IEEE Frontiers in Education Conference
T1A-1
Session T1A
TABLE I
ENGINEERING MAJORS AND RELEVANCE OF MATLAB TOPICS
Theory Programming Data analysis

Plotting, Meshing
Vectors, Matrices

Images – Theory

sheet processing
Audio – Theory

Programming –

Programming –

Audio analysis,
Image analysis,

Dataset/spread-
Conditionals
Matlab User

Functions

synthesis

synthesis

Statistics
Interface

Loops
Applied Physics & Applied Mathematics
Biomedical Engineering
Chemical Engineering
Civil Engineering
Computer Engineering
Computer Science
Electrical Engineering
Earth and Environmental Engineering
Industrial Engineering
Mechanical Engineering
analysis, and effective communication of statistical results. extensions of vectors. Topics of matrix arithmetic, such as
For the successful completion of their project, students are scalar-matrix operations and matrix-matrix operations, are
required to find and present on data related to their project. discussed as part of this session, and important concepts of
The motive behind presenting such data is to make a elemental operations versus matrix operations are pointed out.
convincing argument on the feasibility and/or importance of Vector range notation and the closely related topic of matrix
their project. This typically includes a discussion on indexing, some of the most powerful data manipulation tools
demographic distributions and regression of past data for in Matlab, deserve the most amount of time during this first
prediction of future trends. However, students are free to lecture. Finally, scripting is briefly touched upon as a
choose a point of interest to consider. convenient method of collecting expressions to facilitate
weekly exercises and assignments.
COURSE LECTURES
Lecture 2 – Practical examples of vectors and matrices
The sequence of six Matlab lectures is grouped into three
themes: theory, programming, and data analysis. Introduction During the first lecture, students work only with purely
to the basic theory in numerical computation is intended to theoretical and mostly random numerical data, similar to the
even the otherwise widely varying experience of first-year material presented in typical math classes. The second lecture
students. Fundamental concepts in programming are essential serves to strengthen this material by drawing parallels to real
for computation, in particular when basic methods of matrix data. We select playful audio and image examples, both of
manipulation do not suffice. Data analysis is common to all which effectively convey applications of vector and matrix
fields of engineering and provides the foundation of statistical data structures and data manipulation. Besides using audio and
evaluation. A mapping of themes and individual lecture topics image files as examples of data, this lecture serves to
to engineering majors is presented in Table I. While the theme demonstrate the powerful set of functions, which are standard
of programming is applicable only to selected engineering in the Matlab distribution. Without obtaining instruction on
majors, they comprise the majority of student interest. the intricacies of image formats, image encoding,
representation of sound on a bit/byte level, or even file
I. Theory manipulation, users of Matlab can easily work with these data.
Images are practical and convenient examples of matrices,
Lecture 1 – Interface and the matrix data structure because students have an inherent understanding of images,
This lecture serves to build an understanding of the Matlab drawing on their multimedia and television related savvy.
interface, basic mathematical operations, and the fundamental Simultaneously to making images a motivating example for
matrix manipulation in Matlab, students are taught some
data structure of the matrix. Parallels of the interface are
drawn to a typical calculator: the command window is the fundamental theory about images. This includes the RGB (red,
calculator’s keypad and display, the memory workspace is a green, blue) color space used for display technology,
numerical representation of RGB, and data bandwidth issues
graphical view of the calculator’s memory, etc. Because of its
analytical nature, the workspace of Matlab deserves to be related to images and their temporal extrapolation to video.
emphasized greatly – from experience, students do not use it Because most engineering students have a natural interest for
the field of technology, the theory on bandwidth tends to be
enough to understand and correct problems in their work.
Starting with conventional calculator-like operations, very popular and motivating. A comparison is presented in
students are introduced to scalar and variable arithmetic, class (see Table II). Comprehension of the magnitude of
information data size is important, in particular for the fields
including a discussion on some elementary functions available
in Matlab. Vectors as one-dimensional extensions of scalars of computer science, computer engineering, and electrical
are covered next, followed by matrices as one-dimensional engineering.
1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI
37th ASEE/IEEE Frontiers in Education Conference
T1A-2
Session T1A

FIGURE 1
EXAMPLES FROM IMAGE PROCESSING: (LEFT) ORIGINAL IMAGE; (MIDDLE) CONTRAST AND BRIGHTNESS ADJUSTMENT USING SIMPLE MATRIX-SCALAR OPERATIONS;
(RIGHT) COLOR SPACE CONVERSION USING LOOPS, CONDITIONALS, AND THRESHOLDS.
To further motivate the use of vectors, the inherently
TABLE II sequential and therefore one-dimensional data of sound is used
MATRICES REPRESENTING IMAGE DATA: COMPARISON OF BANDWIDTH
in conjunction with Matlab’s sound functions. Having had
Pixels Size in Size in
pixels Mega bytes significant personal exposure to digital audio through trend-
Example matrix 4x5 20 0.0 setting technology such as the CD player or the iPod, most
(lecture 1) engineering students have a natural interest in the topic of
Small image 320 x 240 x 3 230,400 0.2 audio representation. Using a single channel audio file,
(standard in 1990)
students are presented with tools for loading, playing back,
Computer display 1280 x 1024 x 3 3,932,160 3.7
(standard in 2006) and plotting this type of data. Key concepts from the audio
DVD Video 720 x 480 x 3 x 30 31,104,000 29.7 domain, such as frequency and sampling rate are discussed in
(standard in 2006) class. Data manipulation for vectors similar to that used on
Computer display 1280 x 1024 x 3 x 40 157,286,400 150.0 images is motivated using parallels to sound editing functions.
refreshing at 40
times / sec
Volume amplification and attenuation are demonstrated using
Color images are represented as three-dimensional matrix-scalar multiplication and division.
matrices in Matlab, encoding rows, columns, and color. The II. Programming
relatively high dimensionality makes them excellent
candidates as examples for matrix indexing. For purposes of This section focuses on programming constructs, which
demonstrating data structure manipulation, the lecture focuses primarily address students in the fields of computer science
particularly on addressing discrete scalars and extracting sub- and engineering, electrical engineering, and applied math,
matrices using vector range notation. Analysis of image data is where algorithmic design are key concepts. Programming
motivated by selecting pixels from the image, extracting their constructs include loops, conditionals, and the use of
representative numerical values, and theoretically determining functions.
the color value. Validation is found by visually examining the Lecture 3 – Loops
color image.
Matrix data manipulation is motivated by drawing This lecture is primarily focused on the theory and practice of
parallels to image manipulation software, such as Adobe writing loops. Practical exercises build on the material
Photoshop. Multiplication operations between matrices and discussed in lecture 2. Instead of analyzing existing image and
scalars are related to a simple color contrast adjustment model, audio data, this lecture uses loops to synthesize, i.e. artificially
where multiplication of numbers larger than 1 increase, and produce data in these domains.
division thereof decrease contrast. Similarly, addition The theory of loops is conveyed first through simple
operations between matrices and scalars are compared to a constructs, which use the vector range notation and a loop
simple brightness adjustment model, where addition of variable to access individual elements of a vector. The lecture
integers larger than 1 increase, and subtraction thereof then simulates Matlab’s built-in vector-vector operations, such
decrease brightness. Drawing analogies between the image as elemental multiplication. Because these operations are not
domain and matrix manipulation provide immediate visual readily available in other programming languages, their
feedback, which, besides adding instructional value to the benefit in Matlab can be illustrated by comparing it to the
course, many students consider interesting as determined by alternative of using loops. This example also strengthens key
student evaluations (see Figure 1). concepts, like vector indexing and the use of functions to
Exercises with images in Matlab also animates a determine vector length. The discussion on vectors establishes
discussion on data types, since image data is represented by a the theory which is next applied to higher-dimensional
much more restricted set of values. Concepts of discrete structures, i.e. nested loops for two-dimensional matrices.
values and limited ranges are conveyed during this lecture.
1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI
37th ASEE/IEEE Frontiers in Education Conference
T1A-3
Session T1A

FIGURE 2
EXAMPLES FROM SOUND AND IMAGE SYNTHESIS USING LOOPS: (LEFT) RAINDROP SOUND EFFECT; (MIDDLE) 1D GRADIENT; (RIGHT) 2D GRADIENT.
As a practical example for one-dimensional loops used exercise, the use of conditionals is extended beyond the simple
for vector manipulation, the lecture presents an exercise on if-else construct to include the evaluation of a series of
synthesizing a sound effect of a raindrop. The raindrop sound conditionals as well as boolean operators. The example is
is generated by concatenating a sequence of short vectors, drawn from evaluation of elemental matrix operations, which
each representing a sampled sine wave at a different require that the size of matrices are comparable. If the size of
frequency. A single loop over a selected number of one or both dimensions do not meet this criteria, Matlab
frequencies is defined and, using a common formula for produces an error but does not inform the user about which
sampling a sine wave to produce a set of samples for a given dimension caused the error. To simulate a more user-friendly
frequency, the vector containing the final sound effect samples error message, a series of conditional statements are used in
is gradually constructed (Figure 2). this exercise to evaluate all possible error combinations with
Upon successful completion, this exercise leads to a appropriate error messages for a selected elemental operation
discussion on topics related to signal processing, namely audio between two matrices.
sampling rates, undersampling, and audio quality versus To build on the previously discussed topic of color
sampling rate. While not directly related to programming images and to provide an application of conditionals in a loop
loops, this discussion intends to present some simple yet construct, the final exercise simulates the conversion between
interesting topics in signal processing. color spaces. Specifically, a 24 bit full-color image is
A second exercise for one-dimensional loops, which sets converted to a 3 bit color space, where only 8 base colors are
the foundation for nested loops, draws on the discussion of available. Using nested loop constructs to iterate over the
images and color from lecture 2. The goal of this exercise is to three-dimensional image matrix and conditional statements to
generate an image of gradient color values, such as a gradient compare color intensity values to a selected threshold value,
of black to red. The equivalent tool can be found in most every intensity value in the matrix is changed to a binary high
image processing software packages. This exercise places or low intensity (see Figure 1). Topics of interest related to
emphasis on using loop variables for both indexing into the this problem include the popular method of thresholding,
synthesized image matrix and computing color intensity bandwidth for mobile devices, where color intensity of high
values. For simplification, the color gradient is generated granularity are not required, and the evolution of display
along only one row, requiring students to work with one loop technology.
variable. In a related assignment, the loop construct is The exercise on color intensity thresholding also leads to
extended to a nested loop, where two loop variables are used a short demonstration of animation in Matlab. Instead of
to vary color in two dimensions (Figure 2). defining the previously used threshold as a constant, the value
can be made variable. With a simple extension of
Lecture 4 – Conditionals and Functions
encapsulating the code in another loop iterating over variable
This lecture focuses on conditional statements and use of thresholds, the temporal dimension is encoded. The animation
functions. Along with loop constructs, these two topics based on variable thresholds can be reviewed with ease in
complete the discussion on the foundation of programming Matlab.
with Matlab. Students have thus far used a number of pre-defined
The theory on simple conditional constructs are presented functions. For the second half of this lecture, they are
using the familiar problem of checking the denominator for introduced to writing functions. Emphasis is placed on error
zero values before performing division. While Matlab allows checking using pre-defined methods commonly found in
these operations without bringing a program to halt, other Matlab functions, as well as variable function inputs and
programming languages are not as forgiving. Generally, testing for proper definition of optional arguments using
proper error checking requires the use of conditionals to conditionals.
prevent unexpected failures of programs. In a following

1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI


37th ASEE/IEEE Frontiers in Education Conference
T1A-4
Session T1A

FIGURE 3
EXAMPLES FROM DATA ANALYSIS: (LEFT) PLOTTING, LABELING; (MIDDLE) STATISTICAL MEASURES: MIN, MAX, MEAN; (RIGHT) POLYNOMIAL REGRESSION.
example method of regression. Mean, standard deviation,
III. Data Analysis
variance, minimum, and maximum values are common
Statistical analysis and functions for graphing are some of the measures used in statistics. Similar to many other functions,
most popular features of Matlab. These tools find application these five selected ones share the same syntactic rules for
in all fields of engineering and science, and are thus vectors and matrices. Drawing on the dataset from lecture 5,
indispensable for instruction. In a first-year engineering design statistical and graphical evaluation are demonstrated in this
course based, these tools are also the easiest to link to session (Figure 3).
individual projects, because all projects benefit from some Regression is a statistical tool, which is often used for
statistical analysis. prediction of trends in datasets. Fitting of data to a function is
achieved relatively easily in Matlab with pre-defined
Lecture 5 – Data sets, plotting, meshing functions. While there exist various types of methods for data
This lecture demonstrates the use of datasets, importing of fitting, e.g. to periodic, exponential, and logarithmic functions,
such data into Matlab, and basic elements of graphical this lecture focuses on fitting to polynomials with various
analysis. Datasets of observations are crucial factors of degrees.
evaluation in engineering. Datasets come in various sizes, For an introductory exercise, a second-degree polynomial
some as small as ten and others as large as millions of is fitted to a sampled sine wave of one period (Figure 3).
observations. However, some popular graphical spreadsheet While the fit is almost perfect, drawbacks are demonstrated as
programs, while easy to use due to their interactive nature, are the fitted curve is extended beyond the original data set’s
not designed for evaluation of large datasets. As a fusion domain. Clearly, a fit to a periodic function is required.
between a programming language and a large library of Using the dataset of relatively variable gasoline prices,
commonly used analytical functions, Matlab is especially the following exercise attempts to find a polynomial fit. The
useful for the topic of data analysis. exercise leads to a discussion on optimal fitting versus finding
For the purpose of simplicity, students are introduced to reasonable trends.
the graphical importation tool, which is a graphical interface
of functions otherwise available in Matlab. The lecture ASSESSMENT
provides an example spreadsheet of gasoline price Assessment of student learning has evolved since the
development in various regions throughout the U.S. over a ten introduction of Matlab lecture series. Initially, we assigned
year period. The spreadsheet is properly delineated with row individual homework following each lecture to reinforce the
and column header information, which is used to demonstrate covered lecture material. We soon noticed that students were
the separation between numerical and non-numerical data in completing the assignments by referring to the tutorials and
matrices. Differences of numerical data types were discussed seeking help, but were still unclear about the fundamental
in lecture 2 by introducing images and their restricted set of concepts. However, as long as the student completed his/her
discrete intensity values. Differences and parallels between homework and received a credit for the assignment, the
numerical and textual data are outlined in this session, in student did not seek additional help for clarifying any unclear
particular for the purpose of labeling graphs. concepts.
Two-dimensional plotting and three-dimensional meshing The introduction of an exam at the end of the Matlab
are covered using examples of line and bar graphs, labeling of lecture series served as the solution to this problem. Students
figures, manipulation of axes’ labels and tick marks, and were required to learn concepts rather than relying on course
overlaying of various data sets (Figure 3). materials and previous examples to finish assignments. The
Lecture 6 – Basic statistical analysis comprehensive exam allowed for us to monitor true student
understanding of fundamental concepts. The format of the
After the introduction of graphical analysis tools, students exam tested for theory as well as implementation of code.
now work with some basic statistical functions and an
1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI
37th ASEE/IEEE Frontiers in Education Conference
T1A-5
Session T1A
TABLE III resistance caused by friction, drag caused by mass and
RESOURCE REQUIREMENTS BREAKDOWN FOR THE MATLAB LECTURE-SERIES.
acceleration), which described the amount of force required to
Resource First Time Requirement Subsequent Requirement
Teaching Assistants 4 hours/week 4 hours/week move the mass of the vehicle and the person at some velocity.
Preparation of 1 hour/lecture Equations were introduced for energy from batteries,
15 hours/lecture
Lecture material regenerative breaking, battery inefficiency, propulsive
Actual Lecture 1.5 hours/lecture 1.5 hours/lecture efficiency, etc. With a complete setup of functions, students
However, students were not permitted to use a computer to computed the distance traveled on a hypothetical terrain of
write code. inclines, declines, and level surfaces. While these lectures
We also required that student groups include were much more closely related to engineering, the material
computational analysis using Matlab for their group projects was not absorbed very easily. We have observed that
due at the end of the term. Since one of the goals of the course comparatively, a sequence of topically less specific lectures is
is to show students the real-world application of concepts perceived with more engagement.
learnt in class, this was the ideal solution to show students the
usefulness of Matlab. We notice that the quality of project also RESOURCE REQUIREMENTS AND SUSTAINABILITY
improved with this requirement. Often times, student teams
would propose solutions that were unfeasible due to The implementation and resource requirement for the Matlab
considerations that were not calculated during the scope of lecture-series is comparable to any other college lecture
their design project. Thus, the addition of numerical analysis course. Since the series is embedded into an engineering
to all projects required for students to rethink actual feasibility design course, the total duration for the Matlab aspect is
and in essence increased the success rate of completion as limited to 6 weeks. Table III shows the resource breakdown
more projects could now be taken to prototyping and for the onset of the lecture series followed by subsequent
implementation stages. administrations.
Teaching assistants hold office hours and grade papers.
CHALLENGES The preparation of the initial course material requires the most
amount of time (approximately 90 hours). However, time
A curriculum in a first-year engineering design course with allocation necessary for sustainability drops significantly once
students without major selection offers challenges that are the course material is created. Thus, sustainability of the
uncommon in topically directed courses. The most significant Matlab lecture series within an engineering design course
concern arises from the expected lack of field-specific structure is highly manageable.
knowledge by students. Students’ high school backgrounds
offer little common ground due to the national and CONCLUSION
international diversity of standards. Levels of instruction in
natural and life sciences vary significantly with some students In this paper, we have presented an approach to effectively
excelling at related first-year college courses, and others introducing the use of Matlab in a first-year undergraduate
requiring much additional study. It is commonplace for course engineering design course at Columbia University.
evaluations to contain a uniform distribution of ratings and Introducing students to the software package at an early stage
comments, ranging from too fast/difficult to too slow/easy. It is helpful for the students during their more technical courses
would be reasonable to separate the class into several sections when professors assume some basic familiarity with the
of varying degrees of difficulty; however, this approach is software package. The general student reaction to the use of
principally not the goal of a first-year design course. Matlab has been positive. Providing basic instruction that
A second challenge arises from the variety of project students of all skill-levels can understand provides for a better
categories in a given semester. With more than 30 projects learning experience. Using interesting engineering design
with different problems and implementation goals, it is examples aids in showing students the real-world
infeasible to provide instruction on detailed numerical implementation of this powerful computational tool.
computation satisfying all. We have therefore selected the ACKNOWLEDGMENT
broadly applicable topic of statistical analysis as a common
ground for all projects. The author would like to thank the Fu Foundation of
In an earlier version of the course, engineering design Engineering and Applied Science at Columbia University and
focused on a narrower topic of personal transportation the Gateway Coalition.
vehicles. Matlab lectures linked concepts from physical
mechanics to student projects and students were required to REFERENCES
present on calculations related to their design projects. We [1] Azemi, A., Stoock, C. "Utilizing MATLAB in undergraduate electric
found that this topic proved challenging due to the relatively circuits courses" Frontiers in Education Conference Proceedings, 2,
small number of students who excelled in this field. Three 1996, pp 592-602.
lectures were designed for topics on the physics of the Segway [2] http://www.aquaphoenix.com/lectures
Human Transporter, including computation of estimated [3] Dutta, P., Haubold, A. “Engineering design via team-based service-
battery life. The lecture material set up the theoretical learning projects: Case survey of five unique project genres.” American
framework of various forces (aerodynamic drag, rolling Society of Engineering Education (ASEE) Annual Conference, 2007.

1-4244-1084-3/07/$25.00 ©2007 IEEE October 10 – 13, 2007, Milwaukee, WI


37th ASEE/IEEE Frontiers in Education Conference
T1A-6

You might also like