Rank: 5157 based on 21 downloads (last 30 days) and 1 file submitted
photo

Dimitrios Korkinof

E-mail

Personal Profile:
Professional Interests:
Statistical Machine Learning

 

Watch this Author's files

 

Files Posted by Dimitrios
Updated   File Tags Downloads
(last 30 days)
Comments Rating
18 Apr 2013 Screenshot Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof demo, performance, oop 21 6
  • 4.66667
4.7 | 3 ratings
Comments and Ratings by Dimitrios View all
Updated File Comments Rating
15 Apr 2014 sigstar - add signifiance stars to bar charts, box plots, etc Add significance bars and asterisks to various plot types Author: Rob Campbell

18 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof

Thank you guys! I did not know about the handler classes!

I've tested it and it runs faster indeed, but again slower than nested functions. I will update the submission as soon as possible.

To Josh:
Yes, you are right, the functions do not modify the objects! This was a change I made just before submission, thinking that it would run faster this way. I will update it. Thanks for the comment!

Comments and Ratings on Dimitrios' Files View all
Updated File Comment by Comments Rating
18 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof Sampson, Eric

18 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof Korkinof, Dimitrios

Thank you guys! I did not know about the handler classes!

I've tested it and it runs faster indeed, but again slower than nested functions. I will update the submission as soon as possible.

To Josh:
Yes, you are right, the functions do not modify the objects! This was a change I made just before submission, thinking that it would run faster this way. I will update it. Thanks for the comment!

18 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof Josh

There are two types of classes in MATLAB: value classes and handle classes.

When you call a member function of a value class, MATLAB copies the entire object into the member function space. This is why your code takes so long to run; each time you edit one element in the 400x400 array, MATLAB has to make a copy of the entire array.

If you use a handle class (put "< handle" at the end of the classdef line) then MATLAB only passes a pointer to the class to each member function. Thus, handle classes in MATLAB behave more like classes you're probably used to in other languages, and your code should run MUCH faster if you use a handle class.

Incidentally, you need to return a value from object class methods in order to modify the original object. Your modify_one function doesn't actually modify the c1 and c2 objects you define in PerfTest.m. If you were to examine the value of large_mat after the test code competes, it will still be all zeros.

17 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof isakson, per

I modified and ran your code with R2012a 64bit on Windows 7.

Firstly, I changed the code to return the object for the value-classes, e.g. c1 = modify_one(c1,i,j); That didn't change much.

Secondly, I added two handle-classes, Ch1 and Ch2, based on the value-classes.

My result:

>> PerfTest
time =
core: 0.0627
c1: 6.1896
c2: 1.3763
f: 0.2748
ch1: 0.6555
ch2: 0.5216

The handle-classes perform better than the value-classes.

17 Apr 2013 Performance in object-oriented matlab code A very simple example to demonstrate an observation of mine regarding the use of classes in matlab. Author: Dimitrios Korkinof Woodford, Oliver

Interesting. It would be useful to see how a handle class performs in comparison.

Contact us