File Exchange Pick of the Week

Our best user submissions

Rubik’s Cube + New Programming Features


The file submission referenced in this post is no longer available on File Exchange.

Our loyal readers have probably figured out by now that I'm the goofy one who spends all day looking for fun things to do with MATLAB. So, it surely comes as no surprise that I've picked Alexander Mueller's Rubik's Cube this week. You've got to check this out - besides being a faithful rendering of the classic original, it looks great. He even programmed in my favorite trick - "solving" the puzzle by moving the stickers around instead of the actual pieces.

I've actually got a more serious motivation behind this week's pick. Alexander makes very effective use of two new programming features introduced in MATLAB 7 last year. By using nested functions, he wrote very compact and readable code for a user interface. Alexander created the GUI components in the main function, which makes their handles visible inside all of the nested functions (without having to pass anything around). Alexander also used the new hgtransform graphical object. These allow you to manipulate multiple graphical objects (like patches) as if they were a single object. In his application, this eliminates the very tedious programming of calculating all of the cartesian coordinates for every face of every block in the cube. It's always great for me to see when and how people adopt the new features that we put into the language.

Thanks for the hours of fun and the nice programming lesson, Alexander!

  • print


要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。