Thursday, February 14, 2013

For Want of an Asterisk

Saturday morning.  Nemo has just blanketed Cornell’s campus with four inches of fresh snow.  When I step out of my dorm, the snow is fresh and untouched.  That’s because it’s nine in the morning of the first full day of our weekend.

That’s right.  Nine am and I’m about to embark on a two and a half hour coding journey with MATLAB.  I’m a morning person, so I leave my 7:15 alarm on all weekend and go to bed when people are heading out for the night.  Which is why I had no problems when a friend and my current MATLAB partner suggested meeting early on Saturday morning to take a look at the homework.

Since my parents wouldn’t pay for MATLAB I didn't buy MATLAB for my computer, we went over to the lab at RPCC.  Another plus of starting that early was that the lab was empty except for one other person, and he left after a few minutes, so we didn't have to worry about bothering anyone with our talking.

Two and a half hours . . . sounds an awful lot like our Intro to ChemE homework sessions.  Anyhow, I’d looked at the first problem beforehand, so we got that one done in . . . an hour, maybe.  The second problem I hadn't looked at, so I was doing all the coding as I figured out the problem.  I handwrote the code, typed it into MATLAB, and was trying to test it when I kept getting an error message.  Usually, MATLAB’s good about giving you the problem and which line is causing the problem, and it did this time too, but I couldn't understand what MATLAB was trying to tell me.

I turned to Google to explain the error and got something about an array.  What array?  I don’t even know what an array is or how to program one.

Sixty-seven trials later (and extensive use of the pause function – I was told this would be useful in debugging, but I’m not sure the professor would have expected its use this soon), I found the error.  I was trying to multiply a variable by a quantity and typed it as x(2*k+1).  Yep, I forgot an asterisk.  (It should have been written as x*(2*k+1).)  I typed in the asterisk and the program worked perfectly.

No comments:

Post a Comment