In this class we began to investigate the fun and exciting world of MATLAB! We worked through a series of exercises from the first four chapters of Alan Downey's Physical Modeling in MATLAB. I greatly enjoyed Downey's many humorous asides, and I was thrilled to design and run programs that actually worked! I was excited to program in a text language, though it was a bit less transparent than the highly-visual PicoBlocks; however, I greatly appreciated the informative textbook walkthrough of the basics.
My version of the first exercise, creating a program to print the nth number in a geometric series by calculating it with the recursive formula:
I noticed that the textbook had a rather different approach. Mine worked well enough, but Downey's version was a bit simpler and ultimately made more sense, given the matrix foundation of MATLAB:
The second exercise was to calculate the nth Fibonacci number by using the recursive formula. I noticed that MATLAB is unable to deal with F(0), an advance hint about all the matrix notation.
My program:
After doing a little happy dance when the program printed out 55, I moved on to the next exercise, a word problem:
I later found out that I wasn't supposed to use a "for" loop yet, but Professor Banzaert had demonstrated this technique at the beginning of class, and I was eager to apply my new knowledge.
Next I looped the car program to discover that, after a year, the numbers of cars at A and B would be in equilibrium:
Next I plotted everything; I was thrilled that my (albeit very simple) program worked perfectly the first time it ran!
By the end of the class I was still struggling with the Fibonacci series and the baseball problem, but I hoped to finish them quickly and move on to more exciting programming.




No comments:
Post a Comment