Tuesday, May 18, 2010

MATLAB with Maps

I have more from my MATLAB class. For the latest assignment, I had to create a Simulink model for the equation 5y’’ + 3y’ + 7y = f(t).

When I first tried this, my Simulink block diagram looked like this.

My first block diagram in simulink
While it does not look like much, the settings on the state block can do a lot of things and minimize the need for other blocks. I got here by following the example in the teacher's notes and modifying it for the specific problem. However, some people were having problems with the Simulink stuff. The instructor posed his answers to the questions. This was his rendition of the block diagram I made above.

Teacher's simulink block diagram
Since the text is small, I will explain the action. The signal starts at a generator on the left. This follows the arrow to a sum circle where it continues to the box integrator. It then travels through a triangular multiplier before the signal is duplicated. One copy goes to another integrator box and multiplier triangle. That output and the duplicated signal from earlier are sent back to the sum circle (it can also subtract) where they affect the cycle.

It is a good thing the instructor posted his answer. Aside from the wrongness of what I originally did, it lacked the steps which made it look like I was doing things. I redid my diagram and came up with this.

My modified simulink block diagram
Creating these images was a ruinous process. MATLAB can't save as a jpg, Blogger will not accept PDF uploads, and when I tried to save as an XPS file I ended up with 7 different copies of the file on my desktop, none of which I could open (though I was eventually told .NET framework was necessary). After printing them to a PDF file, opening in Photoshop, cropping, saving as a properly sized jpg, and uploading they became the pictures they are now. This is also why I did not go back and recreate the last picture to be easier to read.

Learning takes...
When referring to the online discussion forums, my teacher said "It takes a village to teach MATLAB simulink." I disagree. All you need is a good video introduction (which we did not have for Simulink), access to the internet to research questions in the technical documentation, and the willingness and persistence to solve problems.

I taught myself a 3D graphic design program for an archeology project from youtube videos. No village was necessary, just a knowledgeable and dedicated teacher.

Now that I know about Simulink, I have to decide the best way to implement my class project. Luckily (or unluckily) I have not written any code for it yet.

Friday, May 14, 2010

Race for the Black-Eyed Susans

Tomorrow is the 135th running of the Preakness Stakes. People will be making their way to see the horses run at Pimlico Race Course in Baltimore. Two weeks ago my post about the Kentucky Derby opened this series.

Will the Derby winner Super Saver win the second crown? Or will he be beaten by Lookin At Lucky who is almost equally favored in the odds? Calvin Borel rode Rachel Alexandra to victory in last year's Preakness, can he repeat the feat with Super Saver? All these questions will be answered tomorrow in the 1 3/16 mile race.

The race website has many race traditions chronicled. There is the singing of "Maryland, My Maryland" and the painting of the winner's colors on the weather vain on the Old Clubhouse cupola.

Also online is the official drink recipe. It is reproduced below, but I use whatever vodka brand I have at hand. In case you are wondering, the Black-Eyed Susan is a flower. It is the state flower of Maryland and the winner of the Preakness is presented with a blanket of the flowers. This lends the race another name, the same way the Kentucky Derby is the Run for the Roses.

Black-Eyed Susan

1 1/4 oz Early Times Kentucky Whiskey
3/4 oz 42 Below Vodka
3 oz Sour Mix
2 oz Orange Juice

Combine and garnish with orange slice and cherry.

I will take this opportunity to add to my post from the Derby a couple of weeks ago. I made some Derby Pie and it had a full stick of butter.


Derby Pie

1 cup sugar
1/2 cup flour
3/4 teaspoon baking powder
1/4 teaspoon salt
2 eggs
1 teaspoon vanilla extract
1 stick butter, melted
1 cup chocolate chips
1 cup pecans, coarsely chopped
1 unbaked pie shell (the recipe insisted upon Pillsbury, but I used Marie Calender's)

Preheat oven to 350. Combine sugar, flour, baking powder, and salt. Add eggs, one at a time, then vanilla and melted butter. Stir in chocolate chips and pecans. Pour into pie shell and bake for 30-40 minutes. Let cool to set.

Wednesday, May 12, 2010

Webcomics and Their Laughs

I regularly read xkcd.com. I first heard about the site from references people made to it. People would say "I saw this on xkcd," or "That reminds me of an xkcd from a while ago."

The site describes itself as: "A webcomic of romance, sarcasm, math, and language." It is a "Stick-figure strip featuring humour about technology, science, mathematics and relationships, by Randall Munroe."

A lot of the comic's humor involves specialized knowledge. For example, many jokes are based upon internet culture or recurring ideas online. I have Googled many terms and people I was not familiar with such as Rickrolling, Richard Stallman, and Rule 34.

There are also computer related jokes. It seems Python can do anything and understanding SQL is a lot of fun when naming a child.

There are many science fiction references. Aside from being up on everything from Ender's Game to Ghostbusters, knowledge of the show Firefly is very helpful. I would recommend you watch all the episodes of Firefly on hulu.com when you have some time. It is a good show, even if the last person I told that to agreed with a wonderful tone of scarsim in her voice. The writer/cartoonist/humorist Randall Munroe also mentions Summer Glau relatively often. Then there are the Star Wars references. Some of these are so subtle I missed them the first time around.

One aspect I enjoy a lot are the science jokes. One of the early ones is great.
xkcd Kepler comic
If you don't get the joke, check out law number two from the Unnamed Geniuses. The quality gets better, since a few of the early ones were scanned in from notebooks before the site was envisioned.

In the language category of humor, irony is on display as well.

There is one last thing. I am almost embarrassed to say I did not know this until after I had read many of the episodes. There is mouseover text for each of the strips. After you read, hover over the image and more text will appear.

This makes it half a dozen links and this makes it seven.

Monday, May 10, 2010

The Oppressive Iron Heel

After reading some of Jack London's works, I wanted to read his dystopian novel The Iron Heel.

A month ago I went to the library and picked up a book of London's novels and social writings published by The Library of America. The collection was the only text that had The Iron Heel in it.

The next day at home I wanted to read something. I pulled out a different book from my own collection and started reading. I liked the short story so much when I was at the library the next day I grabbed a second book of more writings by this author. After I read most of that book, I was at the library again and picked up a third book on a completely unrelated subject and started reading that. Then I picked up a fourth library book, but my Dad started reading it before I could.

After these four other books intervened, I thought I should start reading The Iron Heel before it was due back at the library.

The Iron Heel was published in 1908 and most of the action in the narrative takes place in the subsequent years. It covers how the wealthiest people create an oligarchy which takes control of the country and how people organize against them. The term Iron Heel refers to the Oligarchy's oppressive rule and their ability to crush dissension.

The book has an interesting structure. Most of it is a first person account written by Avis Everhard. She talks about her life as well as the political and social changes that occur within the Unites States. This Everhard Manuscript is then framed with a forward and footnotes from a historian writing hundreds of years in the future. This historian will give background information to some characters and explain how history developed between the manuscript's time and the historian's day hundreds of years later.

The book illuminates London's political and social views. If any lukewarm socialists read this book they will become passionate and devoted socialists. I should mention the Unnamed Geniuses report an entire chapter of the book was plagiarized.

While the early years of the Twentieth Century did not play out as the novel suggests, there is still value in reading the book today. In the last hundred years, socialist empires have risen and fallen. London's ideas, assumptions, and fears can be tracked in real world examples.

I liked The Iron Heel better than any of London's other works I have read, including The Sea-Wolf, The Call of the Wild, and some other stories. This could stem from the more personal writing style or the pseudo-historical nature of the book. I am a fan of history.

If you want another interesting fact, the first half of the book takes place in the town of the University of California, Berkeley.

Sunday, May 9, 2010

12:01 Its showtime

On Thursday night I had a long night out. The afternoon found me drinking water from a collectible Slurpee cup of the first Iron Man movie. This was in preparation to see Iron Man 2 when it opened at midnight. It was a Frank organized event. He bought tickets for the Imax showing at the Regal in the Long Beach Towne Center. Waiting in line, Aden mentioned he was thinking about my road trip game which was then played.

Around 11:30, they let everyone into the theater. I have been to many Imax theaters before and was underwhelmed at the size of the screen. As midnight rolled around, nothing happened. We sat and waited, looking at a gobo that said:

Iron 2 Man
in theaters May 7

At 12:20, a theater manager came out and told everyone they could not find a key to open something for the film. We would not be able to see the film in Imax that night. However, they would give everyone a voucher for a free movie of their choice at the theater and either a refund or a seat in one of two theaters they were opening just for the disappointed Imax people. We chose the later option. A little after 12:30, the previews started. I enjoyed the movie and would recommend it.

This lead me to think of all the movies I have seen at midnight when they opened.
  1. Star Wars Episode III: Revenge of the Sith This conveniently came out the day after my last final freshman year. I saw it with Peter (the Northern California one), Linda, and my Associate.

  2. Pirates of the Caribbean: Dead Man's Chest Saw with my roommates junior year and some other BCR people in Berkeley.

  3. Borat: Cultural Learnings of America for Make Benefit Glorious Nation of Kazakhstan Same people as Pirates II, only a more mob like experience. At one point the crowd outside decided it was time to enter. Everyone walked into the building and tried to find seats with their friends in the four theaters that would show Borat. It was a great experience to laugh with that crowd.

  4. The Dark Knight I saw this with some of the Vietnamese Crew at Metro Pointe. That is probably the best way to describe them. They are people I know from high school who went to UCI. If you ever want to met Bui, Ngo, Pham, Nguyen, and company they are an interesting bunch.

  5. The Crazies Watched it in Orange with the same people as Iron Man 2.

  6. Iron Man 2
Now is as good a time as any to say this. I did not see the first Iron Man movie.

Monday, May 3, 2010

Travel to the Stars with a Book

Saturday was a fun/productive/incredible day. There were mint juleps, a book index that directed me to two pages that were not in the book, and many unanswered questions about fast Fourier transforms (FFT).

Early in the day I was trying to find an idea for my MATLAB class project. After looking through my linear algebra textbooks unsucessifully, I thought of one more book from my collection that might have something inspiring for a project in it.

The book was Fundamentals of Astrodynamics. I originally bought it back in the summer of 2006 at the Barnes & Noble on Bay Street. From the clearance table, this Dover book cost me less than $4. First published in 1971, it is a textbook written by professors Roger R. Bate, Donald D. Mueller, and Jerry E. White at the Air Force Academy to teach about the motion of man-made objects in space.

The book had an appendix with four different programing projects. They were all interesting and I was excited to discover them. Since the projects used the principles discussed in the book, I would have an excellent reference in writing the program. I picked one of the projects and started writing my proposal.

To paraphrase and condense the book's project:
Given the position and velocity of an object in the atmosphere, determine where it will impact the Earth. If the object will not hit, give its point of closest approach. Also determine the time to impact/closest approach, give the type of orbit (circular, rectilinear, elliptical, parabolic, or hyperbolic), and total change in true anomaly from initial observation to impact/closest approach.
Then I started looking through the book to learn what I needed to know to complete the project. The project deadline was a month away, so I started at the beginning of the text. I read carefully and followed all the math from one line to the next. I worked on the examples and did the problems as they came up.

By the time I went to bed I had read all of the first chapter. I had gone through 44 pages of a textbook and understood very nearly every single line, example, and the first few problems at the end. More surprising than that, it all happened in one day.

After my reading I came to a conclusion, astrodynamics is amazing. Starting with Newtons's Laws of Gravity and using them to confirm Kepler's Laws, the book derives how to calculate the orbits of satellites.

Going through the book, I solved a lot of interesting problems and learned some great things. All of the examples used feet and miles. Not just any miles, but nautical miles. In case you are wondering, 1 n.mi.(or NM) = 6076.115 feet (approximate value). For one of the problems, my satellite orbit numbers did not make sense. Then I realized my mistake; I forget about the Earth and the thousands of miles it added to calculations. In case it comes up, the Earth has a mean radius of 3443.92 NM (approx. again).

The book is available directly from Dover Publications. However, the careful searcher will find a preview in Google Books. When I was looking at the preview, I discovered there is a limit to the number of pages of the book that can be viewed, even if almost any page in the book can be chosen for this viewing.

I plan on going through most of the book and doing all of the projects at the end.

Saturday, May 1, 2010

My Patent Pending Road Trip Game

In February of last year, I came up with a road trip game. Actually, this does not have to be played on a long trip, but it is great at generating talk for long periods.

I came up with this game as I was driving to the CRP convention (a political meeting) in the spring of 2009. I stopped to collect Derek in Carpinteria near Santa Barbara before continuing up the 101. To give the complete freeway route, it was the 405 north, to the 101 north, to the 152 East, to the 5 North to Sacramento. I drove over 1,000 miles round trip and spent most of it (~80%) transporting Derek. Before we started this game, Derek was engaged in texting Rohit our progress in the trip. Considering Derek's level of texting experience, writing a text was a prolonged source of entertainment for him.

The Game
The person who starts picks up his phone and asks the other people in the car for a letter. If an R is called out, the person with the phone will go to the letter R in his stored phone numbers and talk about the first person listed under R. For example, the phone person (narrator from now on) will explain how he met that person. This will continue to any interesting stories about the person, what the person is doing now, and the last time he or she was talked to. If anything is unclear, people can ask the narrator questions to clarify the story. After the first person under that letter has been talked about, the narrator moves to the next person and continues in the same manner. The narrator will continue this for a few letters, depending upon the size of the phone book, and then the next person will become the narrator and be given a letter to start telling stories about from his phone.

If the people playing have a large amount of friends in common, everyone can contribute stories about the same people. If there is a lot of difference in who the people know, there are many more relationships that need to be explained. It is a win-win situation.

While this should be obvious, the narrator should tell stories but not engage in gossip.

This is a great game for me to play. I am skilled at telling stories. Also, I almost never delete numbers from my phone. At my last count, I had over 100 names in my phone. The people I know range from kind-hearted and funny, to crazy and misguided, to strange and weird, and all-around interesting. Sometimes I think I need to be a modern day Chaucer and write a new Canterbury Tales.

When I played this with Derek, I talked for 12+ hours. When I dropped Derek off, there were still 30 people I had not yet talked about in my phone.

If you ever do use this game or a variant, please let me know.