# Category Archives: MATLAB

## The “golden moment”

We’re in final exams week right now, and last night students in the MATLAB course took their exam. It included some essay questions asking for their favorite elements of the course and things that might be improved in the course. I loved what one of my students had to say about the assignment in the course he found to be the most interesting, so I’ve gotten permission from him to share it. The lab problem he’s referring to was to write a MATLAB program to implement the bisection method for polynomials.

It is really hard to decide which project I found most interesting; there are quite a few of them. If I had to choose just one though, I would probably have to say the lab set for April 6. I was having a really hard time getting the program to work, I spent a while tweaking it this way and that way. But when you’re making a program that does not work yet, there is this sort of golden moment, a moment when you realize what the missing piece is. I remember that moment on my April 6 lab set. After I realized what it was, I could not type it in fast enough I was so excited just to watch the program work. After hitting the play button, that .3 seconds it takes for MATLAB to process the program felt like forever. I actually was devastated that I got an error, and thought I had done it all wrong once again, but then I remembered I had entered the error command so it would display an error. I actually started laughing out loud in the lab, quite obnoxiously actually.

Yes!  As somebody once said, true learning consists in the debugging process. And that’s where the fun in learning happens to lie, too. Let’s give students as many shots as possible to experience this process themselves.

## Targeting the inverted classroom approach

Image via Wikipedia

A while back I wondered out loud whether it was possible to implement the inverted or “flipped” classroom in a targeted way. Can you invert the classroom for some portions of a course and keep it “normal” for others? Or does inverting the classroom have to be all-or-nothing if it is to work at all? After reading the comments on that piece, I began to think that the targeted approach could work if you handled it right. So I gave it a shot in my linear algebra class (that is coming to a close this week).

The grades in the class come primarily from in-class assessments and take-home assessments. The former are like regular tests and the latter are more like take-home tests with limited collaboration. We had online homework through WeBWorK but otherwise I assigned practice exercises from the book but didn’t take them up. The mix of timed and untimed assessments worked well enough, but the lack of collected homework was not giving us good results. I think the students tended to see the take-home assessments as being the homework, and the WeBWorK and practice problems were just something to look at.

What seemed true to me was that, in order for a targeted inverted classroom approach to work, it has to be packaged differently and carry the weight of significant credit or points in the class. I’ve tried this approach before in other classes but just giving students reading or videos to watch and telling them we’d be doing activities in class rather than a lecture — even assigning  minor credit value to the in-class activity — and you can guess what happened: nobody watched the videos or read the material. The inverted approach didn’t seem different enough to the students to warrant any change in their behaviors toward the class.

So in the linear algebra class, I looked ahead at the course schedule and saw there were at least three points in the class where we were dealing with material that seemed very well-suited to an inverted approach: determinants, eigenvalues and eigenvectors, and inner products. These work well because they start very algorithmically but lead to fairly deep conceptual ideas once the algorithms are over. The out-of-class portions of the inverted approach, where the ball is in the students’ court, can focus on getting the algorithm figured out and getting a taste of the bigger ideas; then the in-class portion can focus on the big ideas. This seems to put the different pieces of the material in the right context — algorithmic stuff in the hands of students, where it plays to their strengths (doing calculations) and conceptual stuff neither in a lecture nor in isolated homework experiences but rather in collaborative work guided by the professor.

To solve the problem of making this approach seem different enough to students, I just stole a page from the sciences and called them “workshops“. In preparation for these three workshops, students needed to watch some videos or read portions of their textbooks and then work through several guided practice exercises to help them meet some baseline competencies they will need before the class meeting. Then, in the class meeting, there would be a five-point quiz taken using clickers over the basic competencies, followed by a set of in-class problems that were done in pairs. A rough draft of work on each of the in-class problems was required at the end of the class meeting, and students were given a couple of days to finish off the final drafts outside of class. The whole package — guided practice, quiz, rough draft, and final draft — counted as a fairly large in-class assessment.

Of course this is precisely what I did every week in the MATLAB course. The only difference is that this is the only way we did things in the MATLAB course. In linear algebra this accounted for three days of class total.

Here are the materials for the workshops we did. The “overview” for each contains a synopsis of the workshop, a list of videos and reading to be done before class, and the guided practice exercises.

The results were really positive. Students really enjoyed doing things this way — it’s way more engaging than a lecture and there is a lot more support than just turning the students out of class to do homework on their own. As you can see, many of the guided practice exercises were just exercises from the textbook — the things I had assigned before but not taken up, only to have them not done at all. Performance on the in-class and take-home assessments went up significantly after introducing workshops.
Additionally, we have three mastery exams that students have to pass with 100% during the course — one on row-reduction, another on matrix operations, and another on determinants. Although determinants form the newest and in some ways the most complex material of these exams, right now that exam has the highest passing rate of the three, and I credit a lot of that to the workshop experience.
So I think the answer to the question “Can the inverted classroom be done in a targeted way?” is YES, provided that:
• The inverted approach is used in distinct graded assignments that are made to look and feel very distinct from other elements of the course.
• Teachers make the expectations for out-of-class student work clear by giving an unambiguous list of competencies prior to the out-of-class work.
• Quality video or reading material is found and used, and not too much of it is assigned. Here, the importance of choosing a textbook — if you must do so — is very important. You have to be able to trust that students can read their books for comprehension on their own outside of class. If not, don’t get the book. I used David Lay’s excellent textbook, plus a mix of Khan Academy videos and my own screencasts.
• Guided practice exercises are selected so that students experience early success when grappling with the material out of class. Again, textbook selection should be made along those lines.
• In-class problems are interesting, tied directly to the competency lists and the guided practice, and are doable within a reasonable time frame.
These would serve as guidelines for any inverted classroom approach, but they are especially important for making sure that student learning is as great or greater than the traditional approach — and again, the idea of distinctness seems to be the key for doing this in a targeted way.
What are your suggestions or experiences about using the inverted or “flipped” classroom in a targeted way like this?

Filed under Clickers, Inverted classroom, Linear algebra, MATLAB, Screencasts

## How the inverted classroom saves students time

Our semester is into its third full week, and most of my time (as you know from checking my Twitter or Facebook feed) is being spent, it seems, on making screencasts for the MATLAB class. I feel like I’ve learned a great deal from a year’s worth of reflection on the first run of the class last spring, and it’s showing in the materials I’m producing and the work the students are giving back.

The whole idea of the inverted classroom has gotten a lot of attention in between the current version of the course and the inaugural run — the time period I think of as the “MATLAB offseason” — through my blogging, conference talks, and everyday conversations at my work. One of my associate deans, off of whom I’ve bounced a number of ideas about this course, related a conversation he recently had with someone about what I’m doing.

Associate Dean: So, Talbert is using this thing called the inverted classroom.

Other person: What’s that all about?

AD: He puts the lectures all online, and instead of lecturing in class he has them do group assignments on various kinds of problems.

OP: Doesn’t that double the amount of time students have to spend on the class?

I’ve never encountered that exact reaction before, although I did mention once that the biggest negative comment from students last year in the MATLAB course was that it took too much time relative to the credit load (1 credit). I liked how my associate dean put the answer:

AD: Well… think about it this way. You are still doing both lecture and “homework”. But which part of that are going to need the most amount of help on?

OP: OK, now I get it.

Exactly. Students are going to need a lot more guidance on the difficult task of assimilating information than they will need on the relatively easy — incredibly easy, in fact — task of receiving a transmission of information. Both phases of the game need to take place in some form, but assimilation is harder, and the probability of sinking massive amounts of time into work that goes nowhere is a lot higher, than in transmission.

I’ve seen some great examples of where the inverted classroom method has actually saved students possibly hours of fruitless labor in the last two weeks.

Today, for instance, we were doing a lab problem set on command line plotting. In one of the tasks, students are asked to produce a 1×2 subplot illustrating the behavior of a two-parameter family of functions. One team was stuck because their M-file wouldn’t execute properly even though their code looked correct. The problem: They used a dash (-) in the title, which causes MATLAB to think that the stuff preceding the dash is a variable name, which wasn’t in the workspace. It’s an innocent error but not one that students with just two weeks of MATLAB under their belts could easily debug themselves. Had they run into this problem outside of class, who knows how much time would have been wasted getting nowhere? But inside class, it was solved in the amount of time it took for them to raise their hands and for me to come over and look.

Another example from today: A team had entered this code:

x = linspace(0,10);
y = 100 - exp(-2*x);
axis([0 15 90 105])
plot(x,y)


They had entered the code without line 3 already but didn’t like the look of the plot, so they added the axis command to try and change the viewing window. But nothing changed. Why? To the trained eye, it’s simple — you have to have something plotted first before you can change the axis. So just reverse lines 3 and 4. But to the untrained eye, again, who knows how much time would be lost in trying to figure this out? Instead I was able to instruct them directly on this, at the conceptual level (How is MATLAB thinking its way through your code?) and they got it. (It wasn’t just me telling them, “You need to switch lines 3 and 4.”)

So above and beyond being more instructionally effective, I’m realizing — and I hope students are too — that the inverted classroom makes student time a lot more efficient, and there’s a much higher success-to-effort ratio than in the traditional mode of teaching.

## An M-file to generate easy-to-row-reduce matrices

In my Linear Algebra class we use a lot of MATLAB — including on our timed tests and all throughout our class meetings. I want to stress to students that using professional-grade technological tools is an essential part of learning a subject whose real-life applications closely involve the use of those tools. However, there are a few essential calculations in linear algebra, the understanding of which benefits from doing by hand. One of those calculations is row-reduction. Nobody does this by hand; but doing it by hand is useful for understanding elementary row operations and for getting a feel for the numerical processes that are going on under the hood. And it helps with understanding later concepts, notably that of the LU factorization of a matrix.

I have students take a mastery exam where they have to reduce a 3×5 or 4×6 matrix to reduced echelon form by hand. They are not allowed any technology on that exam. I’ve learned that making up good matrices for this exam is surprisingly tricky. My first attempt at writing the exam resulted in a nice-looking matrix whose reduced echelon form had mind-bendingly big fractions in it. I want the exam to be about row reduction and not fraction arithmetic, so I  sat down this morning and wrote this MATLAB function called easyRR.m which automatically spits out $m \times n$ random integer matrices whose row-reduction process might involve fractions but which aren’t horrendous:

%% Function to create an mxn matrix that is easy to row-reduce by hand.
% Basic idea: Construct this matrix by building an LU factorization for it
% where both L and U have small integer values.
% R. Talbert, Feb 15, 2011

function A = easyRR(m,n)

%% Create the L in the LU factorization. This matrix encodes the elementary
%% row operations needed to get A to echelon form.

L = randi([-10, 10], [m,m]);

% Replace diagonal elements with 1's:
for i=1:m
L(i,i) = 1;
end

% Zero out all entries above the diagonal:
L = tril(L);

%% Now create the U in the LU factorization, using smaller integers so that
%% the back substitution phase isn't too bad.

% This creates an mxn random integer matrix and zeros out all entries below
% the diagonal.
U = triu(randi([-5,5], [m,n]));

%% The easy-to-reduce matrix is the product of L and U.
A = L*U;



Here’s a screenshot:

The fractions involved here have denominators no larger than 25, which is way more doable for students than what I had been having them work with (sorry, guys).

And, if you happen to have the Symbolic Toolbox for MATLAB, you can add the line latex(sym(A)) to the end and the function will spit out the $\LaTeX$ code for that matrix, for easy copy/paste into the exam.

Anyway, I thought this was useful and so I’m giving it away!

Filed under LaTeX, Linear algebra, Math, MATLAB, Teaching

## How it all works in the MATLAB course

Image via Wikipedia

I’ve put up a few posts and several comments about the inverted classroom this week. A lot of that is because the second iteration of the MATLAB course is coming around at the beginning of February (we have a January term, so spring classes start a little late for us) and that’s done entirely in “inverted” mode. There were a lot of comments in this post about the inverted classroom, and based on some of those comments as well as some questions I got at my Joint Meetings talk on this subject, I thought I’d say a little about how, exactly, this instructional method gets implemented on a day-to-day basis in the MATLAB course.

The MATLAB course meets once a week (Wednesdays) for 75 minutes. This sets up a once-per-week workflow that repeats itself every Wednesday. Here’s how it will go:

1. On Thursday evenings, students are assigned one or more video lectures to watch in advance of the next week’s meeting on Wednesday. The videos are posted to the internet, so students can pause, rewind, and stop/restart at will, and most videos will be posted to YouTube for easy viewing on a mobile device such as a smartphone. Along with the videos will be given a list of actions students will be expected to perform with MATLAB before coming to class and a series of Guided Practice exercises to work through what they see in the videos. Students are expected to start early so that they can ask questions throughout the week as they come up.
2. The Guided Practice exercises are turned in on Wednesday morning prior to the class meeting so that I can read through them quickly for any widespread issues that arise. It’s a light implementation of just-in-time teaching. (By the way: Read the page at that link. That describes something close to the inverted classroom idea.)
3. In the first few minutes of the class meeting on Wednesdays, students take a short quiz designed to assess their completion of the tasks from the Guided Practice. Quizzes are open-MATLAB so they can check their work as they work. The quizzes are taken electronically so that grading is instantaneous (or near-instantaneous, anyway). The quizzes provide individual accountability on the basic competencies for the week.
4. After the quiz, a brief question-and-answer session takes place in which I discuss any issues arising from the Guided Practice or Quiz, and students can ask brief questions as well. However: There is no lecture and no “re-teaching” during this time. The focus is on clearing up issues from student work. If a student asks, “Can you go over how to do ____?” and the blank contains some general topic (like “plotting” or “if-then statements”) I will generally say “no” because the student has had ample opportunities to ask those kinds of questions during the week. Well, rather than just saying “no” I will try to get at what the student’s real question is. “Can you go over plotting?” usually hides a small, good, targeted question on a single specific topic that can be cleared up in no time. Those questions are fine.
5. The remaining time in class (about 60 minutes) is spent by students working in teams on authentic, problem-centered activities highlighting important ideas to be addressed in the course that week.
6. Students turn in a partial draft of their in-class activity at the end of the Wednesday meeting and then turn in a completed draft by 11:00 PM on the following day (Thursday). At this point the cycle repeats itself with a new list of videos, learning objectives, and Guided Practice exercises.

This cycle is a bit different than what I started with last year, when I first ran the course. The in-class problem sets were supposed to be completely done by the end of class; that turned out to be ridiculously unrealistic. I let students turn in the finished products after 48 hours, which was nice for them except that some teams wouldn’t get far on anything during the meetings, intending to do it all outside of class, which then led to having to finish the week’s lab on top of the next week’s out-of-class assignments. To keep traffic moving better, I’m insisting this year that students turn in a reasonably complete rough draft by the end of the hour (I’ll have a rubric for that later) and then the whole thing before Thursday is done; at which point they should have no leftover work competing with the outside viewing and practice.

Also, the names have changed. Last year it was “homework”; this year it’s “guided practice” to emphasize that the exercises are intended to provide, well, guidance and practice. Last year it was “labs”; this year it’s “in-class problem sets” because there are significant differences between these problem sets and actual labs that science classes use. Last year it was videos; this year it’s “lectures”, to emphasize that it’s not the case that there is no lecturing taking place. Words mean a lot.

I estimate that students will spend no more than 1 hour  a week watching video lectures; between 1 and 2 hours a week working through the guided practice; and maybe 1 hour a week in a combination of reviewing old work, coming to office hours, reading and contributing to online discussions, and other class-related tasks. That’s about 3 hours a week, which is pretty typical for a 1-credit class that meets 75 minutes a week, and it’s even better when you consider the inverted model specifically relegates the least cognitively complex tasks to outside of class.

The number-one student complaint I heard last year was that, far from occupying 3 or fewer hours a week of time, it was taking 6, 8, 10 or even more hours a week to complete the out-of-class tasks. That concerns me greatly. Every now and then in any class you’ll have to spend more than the usual “3 hours of work for each hour in class” conversion formula. But if students are spending more than that much on a regular basis, I would want to see what they are doing. There’s no way what I am assigning will take that long, no matter what your background competency or comfort level or what-have-you are, unless there is some serious inefficiency happening in how the work is being done. That concern is manageable if addressed.

Filed under Education, Inverted classroom, MATLAB, Teaching

## The inverted classroom and student self-image

Image via Wikipedia

This week I’ve been immersed in the inverted classroom idea. First, I gave this talk about an inverted linear algebra classroom at the Joint Meetings in New Orleans and had a number of really good conversations afterwards about it. Then, this really nice writeup of an interview I gave for MIT News came out, highlighting the relationship between my MATLAB course and the MIT OpenCourseware Project. And this week, I’ve been planning out the second iteration of that MATLAB course that’s starting in a few weeks, hopefully with the benefit of a year’s worth of experience and reflection on using the inverted classroom to teach technical computing to novices.

One thing that I didn’t talk much about at the Joint Meetings or in the MIT interview was perhaps the most prominent thing about using the inverted classroom model on a day-to-day basis: how students react to it and change as a result of it. I was actually quite surprised that nobody at my Joint Meetings talk asked me a question about this, because honestly, the inverted classroom sounds great on paper, but when you start to imagine the average college student walking in on the first day of class and having this method of instruction described to him, it becomes clear that a significant amount of work is going to have to be done in order to get students — who are already resistant to any change from their accustomed modes of instruction — on board with the plan.

Students do tend to resist the inverted classroom at first. Some forms of resistance are more benign than others. On the benign end of the spectrum there are students with little experience with the course material or its prerequisites who get bogged down on the basic podcast viewing (which takes the place of in-class lectures in this model) or the accompanying guided practice, and instead of actively seeking a resolution to their question will wait for the instructor to clear it up — in class. On the other end is the student who simply doesn’t believe I’m serious when I say there won’t be any lecturing, who then doesn’t do the work, assuming I’ll bail him out somehow — in class. But in the inverted model, students are held responsible for acquiring basic competencies before class so that the hard stuff — what we refer to as assimilation — is the primary focus of the class time.

I break this distinction down for students, but not everybody buys into it. Those who don’t will have to undergo a learning process that usually looks like shock — shock that I won’t reteach them the material they were supposed to have viewed and worked on, while the lab assignment based on that material is going on. This can get very ugly in ways I probably don’t need to describe. Let’s just say that you had better not use the inverted classroom model if you aren’t prepared to put out a constant P.R. effort to convince students of the positive benefits of the model and constantly to assuage student concerns.

I’ve often wondered why students sometimes react so negatively to the inverted classroom model. I’ve come to believe it’s the result of a invasive, false belief that can arise in students about their ability to learn things independently of others — namely, that they simply cannot do so. I have had students tell me this to my face — “I can’t learn [insert topic] unless you lecture to me about it in class first.” Clearly this is not true. Toddlers learn their native language without formal instruction, just by assimilating (there’s that word again) the language going on naturally in their background. We all learn things every day without sitting in a classroom; we may seek out training data first through printed instructions, worked-out examples, YouTube videos, etc., but it’s almost never in a classroom setting. Learning new things on our own initiative and without formal instruction in a classroom setting is as natural to humans as breathing. Indeed you could say that it’s the capacity to learn in this way that makes us human. But somehow many students think otherwise.

Where does this belief come from? I think that it comes from its own instance of assimilation, namely the assimilation of a culture of programmed classroom instruction that takes place from roughly the first grade through the twelfth grade in this country. Students have so few experiences where they pursue and construct their own knowledge that they simply come to believe that they are incapable of doing so. And this belief is propagated most rapidly in mathematics. I’ve been reading in Seymour Papert‘s book Mindstorms: Children, Computers, and Powerful Ideas, and this quote hits this issue right on the head:

Difficulty with school math is often the first step of an invasive intellectual process that leads us all to define ourselves as bundles of aptitudes and ineptitudes, as being “mathematical” or “not mathematical”, “artistic” or “not artistic”, “musical” or “not musical”, “profound” or “superficial”, “intelligent” or “dumb”. Thus deficiency becomes identity and learning is transformed from the early child’s free exploration of the world to a chore beset by insecurities and self-imposed restrictions.

That last sentence (emphasis added) sums it up, doesn’t it? Deficiency becomes identity. Eventually, if a student is robbed of experiences of self-motivated learning, the student eventually adopts a self-image in which she is incapable of self-motivated learning. It is a false self-image that is ultimately dehumanizing.

Which is why I put such stock in the inverted classroom model. I think this method of teaching, along with other learner-centered modes of instruction like problem-based learning, is on the front lines in reversing students’ negative ways of thinking about how they learn. Students may (will?) chafe at the inversion at first. But in the MATLAB course at least, something really cool happened at the end of the semester. I made up a slideshow for students called “Five myths about how you think you learn that CMP 150 has busted”. Among the myths were “I can’t learn unless a professor lectures to me” and “I can’t learn on my own initiative”, and I gave concrete examples of work that the students had done in the class that contradicted these messages. In the end I showed them that through this inverted classroom process they had taken majors strides toward being confident, independent, skill learners and problem-solvers rather than just people who can play the classroom game well. And even the most skeptical students were nodding in agreement. And I think that makes it all worthwhile for everyone.

## Coming up in January

Fall Semester 2010 is in the books, and I’m heading into an extended holiday break with the family. Rather than not blog at all for the next couple of weeks, I’ll be posting (possibly auto-posting) some short items that take a look back at the semester just ended — it was a very eventful one from a teaching standpoint — and a look ahead and what’s coming up in 2011.

I’ll start with the look head to January 2011. We have a January term at my school, and thanks to my membership on the Promotion and Tenure Committee — which does all its review work during January — I’ve been exempt from teaching during Winter Term since 2006 when I was elected to the committee. This year I am on a subcommittee with only three files to review, so I have a relatively luxurious amount of time before Spring semester gets cranked up in February. A time, that is, which is immediately gobbled up by the following:

• I’ll be at the Joint Mathematics Meetings in New Orleans from January 6–9. This will be my first trip to the Joint Meetings since 2002, and I’m pretty excited about it. I will be giving two talks, one in the MAA Session on Undergraduate Cryptology (PDF) about my five-day micro-unit on cryptology for freshmen and the other in the MAA Session on Innovative and Effective Ways to Teach Linear Algebra (PDF) on experimenting with the inverted classroom model in linear algebra. Both of those sessions are loaded with interesting-sounding talks, so I hope to attend the entire session. I also hope to catch up with friends I haven’t seen since, well, 2002 — and maybe connect with some new ones. If you’re attending, let me know!
• The second iteration of the MATLAB course is coming up in the spring as well, and I will be doing some significant redesign work on it based on experiences and data from the first iteration. I’m constantly humbled and gratified by the interest and positive responses that the course has generated in the MATLAB community and elsewhere — and by how much interest and attention the course has received. I’ve had a chance to observe and talk to the alumni from the first run of the course during their Calculus III course that used MATLAB significantly, and their usage habits and feedback have given me some ideas for what should be positive changes in the course. I’ll elaborate on that later.
• I am teaching Linear Algebra again in the spring, as I have done for the last 4-5 years, and this year I am targeting that course for a more robust implementation of inverted classroom techniques. A lot of the students in that course will be MATLAB course alumni, so they will be used to all that inversion. But I’ve had enough experience with peer instruction and classroom response system (“clicker”) use on the one hand from this past semester (which I never blogged about, and I’ll try to remedy that) and inverted classroom approaches in MATLAB on the other that Linear Algebra seems well-positioned to benefit from a combination of these approaches. I’ll be sketching out and planning the course in January.
• Like I said, I used a lot of peer instruction and clickers in calculus this semester with great success (I think; at least the students say so). I’m teaching two more sections of calculus in the spring and will be refining my teaching using these tools. But calculus in the spring has a different flavor than calculus in the fall, so we will see how it goes.
• What I’m reading this January: Teaching with Classroom Response Systems by Derek Bruff; Learning to Solve Problems by David Jonassen; The Craft of Research by Booth, Colomb, and Williams; and catching up on a mountain of articles that accumulated during the semester.
• I’m also reading Geometry and Symmetry by Kinsey, Moore, and Prassidis leading up to an MAA review of the book. The “Prassidis” in the author list is Stratos Prassidis, who was my Ph.D. dissertation advisor.

Throw a couple of consulting projects on top of all that, and you’ve got yourself a busy January!

## This week in screencasting: The polar express

It’s been a little quiet on the screencasting front lately, but in the next couple of weeks my colleague teaching Calculus III will be hitting material for which I volunteered to provide some content: namely, using MATLAB to visualize some of the surfaces and solids used in multiple integration. Yesterday, I finished two of these. The first on is on polar coordinates and polar function plotting in MATLAB:

And the second one is on cylindrical coordinates and plotting two-variable functions in cylindrical coordinates:

MATLAB doesn’t provide a built-in function for plotting in cylindrical coordinates. Instead — and this is either ingenious or annoying depending on how you look at it — to plot something in cylindrical coordinates, you generate all the points you need in cylindrical coordinates and then use the pol2cart function to convert them en masse to cartesian coordinates, then plot the whole thing as usual in cartesian coordinates.

I think this is smart, since by avoiding the use of a specialized function for cylindrical plots and sticking instead to a single command for 3D plotting, you learn one command for all 3D plots and you get to use all the extras available, such as adding a contour plot onto the cylindrical plot. Overloading the pol2cart function so that it can accept and produce the third coordinate makes this all work. Overall I like how MATLAB doesn’t try to make a function for everything but rather creates a well-featured set of relatively simple tools that will do lots of things.

But I can see where some people — especially MATLAB novices — would find all this annoying, since the entire process takes several steps. There’s a workflow diagram for doing this in the screencast, but a better way is to make an M-file that holds all the steps. Here’s the one I flashed briefly at the end of the screencast:


% Script for plotting a cylindrical function.
% Written by Robert Talbert, Ph.D., 10/20/2010

% Theta: Change t1 and t2 to set the starting and ending values for theta.
t1 = 0;
t2 = pi/2;
theta = linspace(t1, t2);

% r: : Change r1 and r2 to set the starting and ending values for theta.
r1 = -5;
r2 = 5;
r = linspace(r1, r2);

% Create meshgrid for inputs:
[theta, r] = meshgrid(theta, r);

% Apply the function to create a matrix of z-values. Change the function to
% match what you want to plot.

z = r*cos(theta);

% Convert to cartesian and plot using mesh:

[x,y,z] = pol2cart(theta, r, z);
mesh(x,y,z)


It would be simple enough to modify this so that it’s a function rather than a script, accepting the arrays theta and r and a function handle for z, and then producing the 3D plot. Or, one could even make an “ez” version where the user just enters a string containing the function s/he wants. If somebody wants to try that out, and you want to share your results, just put the source code in the comments.

The third one in this series will be up later this weekend. It’s on spherical coordinates and it’s pretty much the same process, only using sph2cart instead of pol2cart. There might be a fourth one as well, dealing with some special cases like constant cylindrical/spherical functions (you can’t just say “rho = 5”, because rho has to be a matrix) and how to plot not just the surfaces but the volumes underneath them.

Comments Off on This week in screencasting: The polar express

Filed under Calculus, Engineering, Math, MATLAB, Teaching, Technology

## This week in screencasting: Contour plots in MATLAB

By my count, this past week I produced and posted 22 different screencasts to YouTube! Almost all of those are short instructional videos for our calculus students taking Mastery Exams on precalculus material. But I did make two more MATLAB-oriented screencasts, like last week. These focus on creating contour plots in MATLAB.

Here’s Part 1:

And Part 2:

I found this topic really interesting and fun to screencast about. Contour plots are so useful and simple to understand — anybody who’s ever hiked or camped has probably used one, in the form of a topographical map — and it was fun to explore the eight (!) different commands that MATLAB has for producing them, each command producing a map that fits a different kind of need. There may be even more commands for contour maps that I’m missing.

I probably won’t match this week’s output next week, as I’ll be on the road in Madison, WI on Monday and Tuesday and there are several faculty meetings in the run-up to the start of the semester. But at the very least, I need to go back and do another two-variable function plot screencast because I inexplicably left off surface plots and the EZMESH and EZSURF commands on last week’s screencasts.

Comments Off on This week in screencasting: Contour plots in MATLAB

Filed under Calculus, Educational technology, Math, MATLAB, Screencasts, Technology

## The semester in review

Image via Wikipedia

I’ve made it to the end of another semester. Classes ended on Friday, and we have final exams this coming week. It’s been a long and full semester, as you can see by the relative lack of posting going on here since around October. How did things go?

Well, first of all I had a record course load this time around — four different courses, one of which was the MATLAB course that was brand new and outside my main discipline; plus an independent study that was more like an undergraduate research project, and so it required almost as much prep time from me as a regular course.

The Functions and Models class (formerly known as Pre-calculus) has been one of my favorites to teach here, and this class was no exception. We do precalculus a bit differently here, focusing on using functions as data modeling tools, so the main meat of the course is simply looking at data and asking, Are the data linear? If not, are they best fit by a logarithmic, exponential, or power function? Or a polynomial? And what should be the degree of that polynomial? And so on. I enjoy this class because it’s primed for the kind of studio teaching that I’ve come to enjoy. I just bring in some data I’ve found, or which the students have collected, and we play with the data. And these are mainly students who, by virtue of having placed below calculus on our placement exam, have been used to a dry, lecture-oriented math environment, and it’s very cool to see them light up and have fun with math for a change. It was a small class (seven students) and we had fun and learned a lot.

The Calculus class was challenging, as you can tell from my boxplots posts (first post, second post). The grades in the class were nowhere near where I wanted them to be, nor for the students (I hope). I think every instructor is going to have a class every now and then where this happens, and the challenge is to find the lesson to learn and then learn them. If you read those two boxplots posts, you can see some of the lessons and information that I’ve gleaned, and in the fall when I teach two sections of this course there could be some significant changes with respect to getting more active work into the class and more passive work outside the class.

Linear Algebra was a delight. This year we increased the credit load of this class from three hours to four, and the extra hour a week has really transformed what we can do with the course. I had a big class of 15 students (that’s big for us), many of whom are as sharp as you’ll find among undergraduates, and all of whom possess a keen sense of humor and a strong work ethic that makes learning a difficult subject quite doable. I’ll be posting later about their application projects and poster session, which were both terrific.

Computer Tools for Problem Solving (aka the MATLAB course) was a tale of two halves of the semester. The first half of the semester was quite a struggle — against a relatively low comfort level around technology with the students and against the students’ expectations for my teaching. But I tried to listen to the students, giving them weekly questionnaires about how the class is going, and engaging in an ongoing dialogue about what we could be doing better. We made some changes to the course on the fly that didn’t dumb the course down but which made the learning objectives and expectations a lot clearer, and they responded extremely well. By the end of the course, I daresay they were having fun with MATLAB. And more importantly, I was receiving reports from my colleagues that those students were using MATLAB spontaneously to do tasks in those courses. That was the main goal of the course for me — get students to the point where they are comfortable and fluent enough with MATLAB that they’ll pull it up and use it effectively without being told to do so. There are some changes I need to make to next year’s offering of the course, but I’m glad to see that the students were able to come out of the course doing what I wanted them to do.

The independent study on finite fields and applications was quite a trip. Andrew Newman, the young man doing the study with me, is one of the brightest young mathematicians with whom I’ve worked in my whole career, and he took on the project with both hands from the very beginning. The idea was to read through parts of Mullen and Mummert to get basic background in finite field theory; then narrow down his reading to a particular application; then dive in deep to that application. Washington’s book on elliptic curves ended up being the primary text, though, and Andrew ended up studying elliptic curve cryptography and the Diffie-Hellman decision problem. Every independent study has a creative project requirement attached, and his was to implement the decision problem in Sage. He’s currently writing up a paper on his research and we hope to get it published in Mathematics Exchange. (Disclaimer: I’m on the editorial board of Math Exchange.) In the middle of the semester, Andrew found out that he’d been accepted into the summer REU on mathematical cryptology at Northern Kentucky University/University of Cincinnati, and he’ll be heading out there in a few weeks to study (probably) multivariate public-key systems for the summer. I’m extremely proud of Andrew and what he’s been able to do this semester — he certainly knows a lot more about finite fields and elliptic curve crypto than I do now.

In between all the teaching, here are some other things I was able to do:

• Went to the ICTCM in Chicago and presented a couple of papers. Here’s the Prezi for the MATLAB course presentation. Both of those papers are currently being written up for publication in the conference proceedings.
• Helped with hosting the Indiana MAA spring meetings at our place, and I finished up my three-year term as Student Activities Coordinator by putting together this year’s Indiana College Mathematics Competition.
• Did a little consulting work, which I can’t really talk about thanks to the NDA I signed.
• I got a new Macbook Pro thanks to my college’s generous technology grant system. Of course Apple refreshed the Macbook Pro lineup mere weeks later, but them’s the breaks.
• I’m sure there’s more, but I’ve got finals on the brain right now.

In another post I’ll talk about what’s coming up for me this summer and look ahead to the fall.

Comments Off on The semester in review