Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Advanced MATLAB: Class system for OOP in MATLAB introduction 10

Posted by Doug Hull,

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.

10 CommentsOldest to Newest

J.Paul R replied on : 1 of 10
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: Steve used binary lookup tables and the image processing toolbox for a "vectorized" approach which would presumably be faster.
Doug replied on : 2 of 10
Thank you. I must have "cleaned up" my code accidentally. Problem has been solved and updated in the File Exchange! Doug
DanK replied on : 3 of 10
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
emorkay replied on : 5 of 10
Hi, This video really helped me a lot. I would like to know where the script file that you later created to perform operations like creating the constructor etc should be located. Thanks,
XAvier replied on : 7 of 10
Thanks a lot for the video, it helps a lot, as an example to start to use classes in Matlab.
Markus Kruger replied on : 8 of 10
Thank you very much Doug, this was much more useful than the last 3 days of going through how to manuals on the web. I wish I found this earlier. Thanks again.
ebru55 replied on : 10 of 10
Hey what did you do on line 19 -41 when you write the Function for Step by Step can you explain this short thank you