Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Doug’s Pick of the Week

July 7th, 2008

Advanced MATLAB: Class system for OOP in MATLAB introduction

This week we will be looking at the MATLAB class system. This video does not cover the “why” of doing OOP (Object Oriented Programming) in MATLAB. It just covers a very simple example of doing OOP.

The ten minute video shows an implementation of Conway’s Game of Life in MATLAB with classes. Though it is not covered in the video, you can implement other lifelike Cellular Automation algorithms by altering the parameters for survival and birth.

iconFiles.jpgiconPod.jpg

3 Responses to “Advanced MATLAB: Class system for OOP in MATLAB introduction”

  1. J.Paul R replied on :

    Nice, but there seems to be a bug in the included files. On line 19 you look for a (presumed) property countSelf, which doesn’t exist. Adding countSelf = false; (or countSelf=true;) in the property section fixes this.

    For an alternative implementation, see:
    http://blogs.mathworks.com/steve/2008/05/20/lookup-tables-conway-game-life/

    Steve used binary lookup tables and the image processing toolbox for a “vectorized” approach which would presumably be faster.

  2. Doug replied on :

    Thank you. I must have “cleaned up” my code accidentally. Problem has been solved and updated in the File Exchange!

    Doug

  3. DanK replied on :

    Doug,
    A very nice and timely blog, since I’m just starting the learning of MatLab OOP this week. I would like to mention one glaring hole in the documentation, etc. which is that there are virtually no examples of classes where the methods are not contained in the classdef file. The project which I’m now applying OOP to has something like 30 subfunctions with about 8,000 lines of code, so I don’t want to try to stick it all in one monster file. Likewise I was most unsatisfied with the documentation on packages. Overall, I think it will take me a while to get used to thinking in OOP, but I see potential benefits, and this blog did provide some help in terms of a framework.

    Thanks,
    Dan

Leave a Reply


Doug Hull is an Application Engineer at The MathWorks. A MATLAB user since 1994, he gets paid to live, eat, and breathe MATLAB! This blog is dedicated to promoting the File Exchange by highlighting files and original video content.



  • pierre: Hi sherryl and thank you for answering me, Actually, I already tried before to use this property because I...
  • Sherryl: In Response to Post #10 by Bryan - Hi Bryan, By default the analog input object will acquire one second...
  • Sherryl: Hello Pierre, Please look at the OutOfDataMode property. http://www.mathworks .com/access/helpd...
  • Scott Hirsch: Elya - In v7.0, try aviread. This has straightforward syntax for reading a single frame - you could...
  • Scott Hirsch: Eric - That’s a nice suggestion. I often get frustrated when debugging GUIDE guis and ending up...
  • pierre: Hi all, I have the Data Acquisition Toolbox, and I’m trying for 2 weeks to send a step voltage, and...
  • Eric S: It would be great to stop the debugger from coughing somewhere inside the more “internal̶ 1;...
  • Tareq: coef1 = rand(1,3)-0.5; coef2 = rand(1,3)-0.5; lex1=roots(polyder(c oef1)) lex2=roots(polyder(c oef2)) hold all...
  • Luca Balbi: While we’re at it… Checking for a number to be zero is tricky in itself. We’re better...
  • david: perhaps some error checking is in order. After all, it is possible that our randomly generated quadratic...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.

Related Topics